Merge "Close .vector-menu-dropdown menus in modern Vector beforeunload"

This commit is contained in:
jenkins-bot 2021-12-14 22:53:54 +00:00 committed by Gerrit Code Review
commit b538d23c57
1 changed files with 14 additions and 0 deletions

View File

@ -33,6 +33,19 @@ function bindToggleOnSpaceEnter() {
} );
}
/**
* T295085: Close all dropdown menus when page is unloaded to prevent them from
* being open when navigating back to a page.
*/
function bindCloseOnUnload() {
addEventListener( 'beforeunload', function () {
document.querySelectorAll( CHECKBOX_HACK_CHECKBOX_SELECTOR + ':checked' )
.forEach( function ( checkbox ) {
/** @type {HTMLInputElement} */ ( checkbox ).checked = false;
} );
} );
}
/**
* Make sure that clicking outside a menu closes it.
*/
@ -99,4 +112,5 @@ mw.hook( 'util.addPortletLink' ).add( addPortletLinkHandler );
module.exports = function dropdownMenus() {
closeDropdownsOnClickOutside();
bindToggleOnSpaceEnter();
bindCloseOnUnload();
};