File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -383,21 +383,26 @@ class GuiControl {
383383
384384 const confirmAction = ( ) => {
385385 dialog [ 0 ] . close ( ) ;
386- $ ( document ) . off ( "keydown.informationDialog" ) ;
387- resolve ( ) ;
388386 } ;
389387
390388 buttonConfirm . on ( "click" , confirmAction ) ;
391389
392390 // Add Enter key support for single-choice dialog
393- $ ( document ) . off ( "keydown.informationDialog" ) ;
394- $ ( document ) . on ( "keydown.informationDialog" , ( e ) => {
391+ const handleKeydown = ( e ) => {
395392 // Only trigger if Enter is pressed, dialog is open, and target is not an input/textarea
396393 if ( e . which === 13 && dialog [ 0 ] . open && ! $ ( e . target ) . is ( "input, textarea" ) ) {
397394 e . preventDefault ( ) ;
398395 confirmAction ( ) ;
399396 }
400- } ) ;
397+ } ;
398+
399+ $ ( document ) . on ( "keydown.informationDialog" , handleKeydown ) ;
400+
401+ // Clean up event listener when dialog closes
402+ dialog [ 0 ] . addEventListener ( "close" , ( ) => {
403+ $ ( document ) . off ( "keydown.informationDialog" , handleKeydown ) ;
404+ resolve ( ) ;
405+ } , { once : true } ) ;
401406
402407 dialog [ 0 ] . showModal ( ) ;
403408 } ) ;
You can’t perform that action at this time.
0 commit comments