From: Bartosz DziewoƄski Date: Fri, 7 Sep 2018 17:58:34 +0000 (+0200) Subject: mw.special.preferences/confirmClose: Catch clicks inside OOUI dropdowns X-Git-Tag: 1.34.0-rc.0~4162^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=3cd6154a72f6ffe5dcaba4a5370b2e689bf11dcf;p=lhc%2Fweb%2Fwiklou.git mw.special.preferences/confirmClose: Catch clicks inside OOUI dropdowns I did what needed to be done. I am not proud of it. Bug: T203825 Change-Id: I57d6177cfb50641d8e085a48258e321e4d028712 --- diff --git a/resources/src/mediawiki.special.preferences/confirmClose.js b/resources/src/mediawiki.special.preferences/confirmClose.js index bf65ae92b9..c092682984 100644 --- a/resources/src/mediawiki.special.preferences/confirmClose.js +++ b/resources/src/mediawiki.special.preferences/confirmClose.js @@ -52,8 +52,18 @@ // Disable the button to save preferences unless preferences have changed // Check if preferences have been changed before JS has finished loading saveButton.setDisabled( !isPrefsChanged() ); - $( '#preferences .oo-ui-fieldsetLayout' ).on( 'change keyup mouseup', function () { - saveButton.setDisabled( !isPrefsChanged() ); + // Attach capturing event handlers to the document, to catch events inside OOUI dropdowns: + // * Use capture because OO.ui.SelectWidget also does, and it stops event propagation, + // so the event is not fired on descendant elements + // * Attach to the document because the dropdowns are in the .oo-ui-defaultOverlay element + // (and it doesn't exist yet at this point, so we can't attach them to it) + [ 'change', 'keyup', 'mouseup' ].forEach( function ( eventType ) { + document.addEventListener( eventType, function () { + // Make sure SelectWidget's event handlers run first + setTimeout( function () { + saveButton.setDisabled( !isPrefsChanged() ); + } ); + }, true ); } ); } else { // Disable the button to save preferences unless preferences have changed