File tree Expand file tree Collapse file tree
resources/js/wysiwyg/ui/framework Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,12 +72,23 @@ export class EditorFormModal extends EditorContainerUiElement {
7272
7373 const wrapper = el ( 'div' , { class : 'editor-modal-wrapper' } , [ modal ] ) ;
7474
75+ // Handle clicks but only when not started from within the modal
76+ let mouseDownInModal = false ;
77+ modal . addEventListener ( 'mousedown' , ( ) => {
78+ mouseDownInModal = true ;
79+ } ) ;
80+ wrapper . addEventListener ( 'mouseup' , ( ) => {
81+ window . setTimeout ( ( ) => {
82+ mouseDownInModal = false ;
83+ } , 10 ) ;
84+ } ) ;
7585 wrapper . addEventListener ( 'click' , event => {
76- if ( event . target && ! modal . contains ( event . target as HTMLElement ) ) {
86+ if ( ! mouseDownInModal ) {
7787 this . hide ( ) ;
7888 }
7989 } ) ;
8090
91+ // Handle escape key press
8192 wrapper . addEventListener ( 'keydown' , event => {
8293 if ( event . key === 'Escape' ) {
8394 this . hide ( ) ;
You can’t perform that action at this time.
0 commit comments