File tree 1 file changed +6
-4
lines changed
app/javascript/blacklight
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -148,13 +148,15 @@ const Modal = (() => {
148
148
} ;
149
149
150
150
modal . setupModal = function ( ) {
151
- // Register both trigger and preserve selectors in ONE event handler, combining
152
- // into one selector with a comma, so if something matches BOTH selectors, it
153
- // still only gets the event handler called once.
151
+ // Register several click handlers in ONE event handler for efficiency
152
+ //
153
+ // * close button OR click on backdrop (modal.modalSelector) closes modal
154
+ // * trigger and preserve link in modal functionality -- if somethign matches both trigger and
155
+ // preserve, still only called once.
154
156
document . addEventListener ( 'click' , ( e ) => {
155
157
if ( e . target . closest ( `${ modal . triggerLinkSelector } , ${ modal . preserveLinkSelector } ` ) )
156
158
modal . modalAjaxLinkClick ( e )
157
- else if ( e . target . closest ( '[data-bl-dismiss="modal"]' ) )
159
+ else if ( e . target . matches ( ` ${ modal . modalSelector } ` ) || e . target . closest ( '[data-bl-dismiss="modal"]' ) )
158
160
modal . hide ( )
159
161
} )
160
162
} ;
You can’t perform that action at this time.
0 commit comments