Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.

Update listener options on useDismissable

+13 -10
+13 -10
src/useDismissable.ts
··· 87 87 } 88 88 } 89 89 90 + const opts = { capture: true } as any; 91 + const touchOpts = { capture: true, passive: false } as any; 92 + 90 93 if (focusLoss) { 91 - root.addEventListener('focusout', onFocusOut, true); 92 - root.addEventListener('focusin', onFocusIn, true); 94 + root.addEventListener('focusout', onFocusOut, opts); 95 + root.addEventListener('focusin', onFocusIn, opts); 93 96 } 94 97 95 - root.addEventListener('click', onClick, true); 96 - root.addEventListener('touchstart', onClick, true); 97 - root.addEventListener('keydown', onKey, true); 98 + root.addEventListener('click', onClick, opts); 99 + root.addEventListener('touchstart', onClick, touchOpts); 100 + root.addEventListener('keydown', onKey, opts); 98 101 99 102 return () => { 100 103 if (focusLoss) { 101 - root.removeEventListener('focusout', onFocusOut, true); 102 - root.removeEventListener('focusin', onFocusIn, true); 104 + root.removeEventListener('focusout', onFocusOut, opts); 105 + root.removeEventListener('focusin', onFocusIn, opts); 103 106 } 104 107 105 - root.removeEventListener('click', onClick, true); 106 - root.removeEventListener('touchstart', onClick, true); 107 - root.removeEventListener('keydown', onKey, true); 108 + root.removeEventListener('click', onClick, opts); 109 + root.removeEventListener('touchstart', onClick, touchOpts); 110 + root.removeEventListener('keydown', onKey, opts); 108 111 }; 109 112 }, [ref.current, hasPriority, disabled, focusLoss]); 110 113 }