Fix focus gone wrong

This commit is contained in:
Lim Chee Aun 2023-09-15 01:10:58 +08:00
parent 020d8e3631
commit f3b81bc540

View file

@ -39,7 +39,9 @@ function Modal({ children, onClose, onClick, class: className }) {
}}
tabIndex="-1"
onFocus={(e) => {
modalRef.current?.querySelector?.('[tabindex="-1"]')?.focus?.();
if (e.target === e.currentTarget) {
modalRef.current?.querySelector?.('[tabindex="-1"]')?.focus?.();
}
}}
>
{children}