tangled
alpha
login
or
join now
kitten.sh
/
use-interactions
0
fork
atom
Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.
0
fork
atom
overview
issues
pulls
pipelines
Update listener options on useDismissable
kitten.sh
2 years ago
fb9ab145
2cf13555
+13
-10
1 changed file
expand all
collapse all
unified
split
src
useDismissable.ts
+13
-10
src/useDismissable.ts
···
87
87
}
88
88
}
89
89
90
90
+
const opts = { capture: true } as any;
91
91
+
const touchOpts = { capture: true, passive: false } as any;
92
92
+
90
93
if (focusLoss) {
91
91
-
root.addEventListener('focusout', onFocusOut, true);
92
92
-
root.addEventListener('focusin', onFocusIn, true);
94
94
+
root.addEventListener('focusout', onFocusOut, opts);
95
95
+
root.addEventListener('focusin', onFocusIn, opts);
93
96
}
94
97
95
95
-
root.addEventListener('click', onClick, true);
96
96
-
root.addEventListener('touchstart', onClick, true);
97
97
-
root.addEventListener('keydown', onKey, true);
98
98
+
root.addEventListener('click', onClick, opts);
99
99
+
root.addEventListener('touchstart', onClick, touchOpts);
100
100
+
root.addEventListener('keydown', onKey, opts);
98
101
99
102
return () => {
100
103
if (focusLoss) {
101
101
-
root.removeEventListener('focusout', onFocusOut, true);
102
102
-
root.removeEventListener('focusin', onFocusIn, true);
104
104
+
root.removeEventListener('focusout', onFocusOut, opts);
105
105
+
root.removeEventListener('focusin', onFocusIn, opts);
103
106
}
104
107
105
105
-
root.removeEventListener('click', onClick, true);
106
106
-
root.removeEventListener('touchstart', onClick, true);
107
107
-
root.removeEventListener('keydown', onKey, true);
108
108
+
root.removeEventListener('click', onClick, opts);
109
109
+
root.removeEventListener('touchstart', onClick, touchOpts);
110
110
+
root.removeEventListener('keydown', onKey, opts);
108
111
};
109
112
}, [ref.current, hasPriority, disabled, focusLoss]);
110
113
}