mediawiki-skins-Vector/resources/skins.vector.js/dropdownMenus.js
jdlrobson 41d30615a2 [modern] Usability improvements to dropdown
* Don't reveal the menu on hover
* Don't flip the dropdown arrow when open
* Menus close when clicked outside

Bug: T275681
Change-Id: I36f5c46422725a935c962be3194fd37bde1fa769
2021-03-07 18:59:41 +00:00

18 lines
538 B
JavaScript

/**
* Make sure that clicking outside a menu closes it.
*/
function closeDropdownsOnClickOutside() {
$( document.body ).on( 'click', function ( ev ) {
var $closestPortlet = $( ev.target ).closest( '.mw-portlet' );
// Uncheck (close) any menus that are open.
// eslint-disable-next-line no-jquery/no-global-selector
$( '.vector-menu-checkbox:checked' ).not(
$closestPortlet.find( '.vector-menu-checkbox' )
).prop( 'checked', false );
} );
}
module.exports = function dropdownMenus() {
closeDropdownsOnClickOutside();
};