File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
app/javascript/blacklight-frontend Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -148,13 +148,15 @@ const Modal = (() => {
148148 } ;
149149
150150 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.
154156 document . addEventListener ( 'click' , ( e ) => {
155157 if ( e . target . closest ( `${ modal . triggerLinkSelector } , ${ modal . preserveLinkSelector } ` ) )
156158 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"]' ) )
158160 modal . hide ( )
159161 } )
160162 } ;
You can’t perform that action at this time.
0 commit comments