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