File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
packages/kit-headless/src/components/modal Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,12 @@ export const Modal = component$((props: ModalProps) => {
50
50
51
51
const focusTrap = trapFocus ( modal ) ;
52
52
53
- const escapeKeydownHandler = overrideNativeDialogEscapeBehaviorWith (
54
- ( ) => ( showSig . value = false ) ,
53
+ window . addEventListener (
54
+ 'keydown' ,
55
+ overrideNativeDialogEscapeBehaviorWith ( ( ) => ( showSig . value = false ) ) ,
56
+ { once : true } ,
55
57
) ;
56
58
57
- window . addEventListener ( 'keydown' , escapeKeydownHandler ) ;
58
-
59
59
if ( isOpen ) {
60
60
showModal ( modal ) ;
61
61
props . onShow$ ?.( ) ;
@@ -71,7 +71,6 @@ export const Modal = component$((props: ModalProps) => {
71
71
cleanup ( ( ) => {
72
72
deactivateFocusTrap ( focusTrap ) ;
73
73
keepModalInPlaceWhileScrollbarReappears ( scrollbar , modalRefSig . value ) ;
74
- window . removeEventListener ( 'keydown' , escapeKeydownHandler ) ;
75
74
} ) ;
76
75
} ) ;
77
76
You can’t perform that action at this time.
0 commit comments