mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-12 09:21:11 +00:00
Sticky header logout goes via API avoiding a second click
Bug: T324638 Change-Id: I59a192863706f1d2a09ec59090c0b099ced8cde0
This commit is contained in:
parent
61901f8b2d
commit
d16d7e80d9
|
@ -382,6 +382,11 @@ function addVisualEditorHooks( stickyIntersection, observer ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Clones the existing user menu (excluding items added by gadgets) and adds to the sticky header
|
||||
* ensuring it is not focusable and that elements are no longer collapsible (since the sticky header
|
||||
* itself collapses at low resolutions) and updates click tracking event names. Also wires up the
|
||||
* logout link so it works in a single click.
|
||||
*
|
||||
* @param {Element} userMenu
|
||||
* @return {Element} cloned userMenu
|
||||
*/
|
||||
|
@ -404,6 +409,16 @@ function prepareUserMenu( userMenu ) {
|
|||
if ( userMenuCheckbox ) {
|
||||
userMenuCheckbox.setAttribute( 'tabindex', '-1' );
|
||||
}
|
||||
|
||||
// Make the logout go through the API (T324638)
|
||||
const logoutLink = userMenuClone.querySelector( '#pt-logout-sticky-header a' );
|
||||
if ( logoutLink ) {
|
||||
logoutLink.addEventListener( 'click', function ( ev ) {
|
||||
ev.preventDefault();
|
||||
// @ts-ignore
|
||||
mw.hook( 'skin.logout' ).fire( this.href );
|
||||
} );
|
||||
}
|
||||
return userMenuClone;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue