Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/components/common/QRTicket/QRTicketModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export default function QRTicketModal({ isOpen, onClose, ticket }) {
useEffect(() => {
if (!isOpen || !modalRef.current) return;

const focusableElements = modalRef.current.querySelectorAll(
const modalNode = modalRef.current;
const focusableElements = modalNode.querySelectorAll(
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);

Expand All @@ -97,16 +98,14 @@ export default function QRTicketModal({ isOpen, onClose, ticket }) {
}
};

modalRef.current.addEventListener("keydown", handleFocusTrap);
modalNode.addEventListener("keydown", handleFocusTrap);
// Focus the modal automatically
modalRef.current.focus();
modalNode.focus();

return () => {
if (modalRef.current) {
modalRef.current.removeEventListener("keydown", handleFocusTrap);
}
modalNode.removeEventListener("keydown", handleFocusTrap);
};
}, [isOpen, handleFocusTrap]);
}, [isOpen]);

const handleShare = async () => {
const shareUrl = ticket?.qrValue || window.location.href;
Expand Down Expand Up @@ -269,4 +268,4 @@ function ShareIcon() {
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/>
</svg>
);
}
}
Loading