File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
packages/kit-headless/src/components/modal Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,11 @@ export const Modal = component$((props: ModalProps) => {
49
49
50
50
const focusTrap = trapFocus ( modal ) ;
51
51
52
- window . addEventListener (
53
- 'keydown' ,
54
- overrideNativeDialogEscapeBehaviorWith ( ( ) => ( showSig . value = false ) ) ,
55
- { once : true } ,
56
- ) ;
52
+ const escapeKeyListener = overrideNativeDialogEscapeBehaviorWith ( ( ) => {
53
+ showSig . value = false ;
54
+ } ) ;
55
+
56
+ window . addEventListener ( 'keydown' , escapeKeyListener ) ;
57
57
58
58
if ( isOpen ) {
59
59
// HACK: keep modal scroll position in place with iOS
@@ -72,6 +72,7 @@ export const Modal = component$((props: ModalProps) => {
72
72
73
73
cleanup ( ( ) => {
74
74
deactivateFocusTrap ( focusTrap ) ;
75
+ window . removeEventListener ( 'keydown' , escapeKeyListener ) ;
75
76
} ) ;
76
77
} ) ;
77
78
You can’t perform that action at this time.
0 commit comments