From f3b81bc54064938448fe89a22d356ecd853ea1d0 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun <cheeaun@gmail.com> Date: Fri, 15 Sep 2023 01:10:58 +0800 Subject: [PATCH] Fix focus gone wrong --- src/components/modal.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/modal.jsx b/src/components/modal.jsx index 34b0a58b..2fc00fba 100644 --- a/src/components/modal.jsx +++ b/src/components/modal.jsx @@ -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}