From 0c074ec91a41e79f403da750fe0c0757e21e1227 Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Thu, 17 Feb 2022 09:46:30 -0800 Subject: [PATCH] Clicking Echo badge should close ULS dialog Bug: T295796 Change-Id: I3a7f33cad4e08ce22b6e640901c965d764c9156b --- modules/ext.echo.init.js | 8 +++++--- modules/ui/mw.echo.ui.BadgeLinkWidget.js | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/ext.echo.init.js b/modules/ext.echo.init.js index da254759d..8723f8290 100644 --- a/modules/ext.echo.init.js +++ b/modules/ext.echo.init.js @@ -234,7 +234,9 @@ function initDesktop() { $badge = $( this ), clickedSection = $badge.parent().prop( 'id' ) === 'pt-notifications-alert' ? 'alert' : 'message'; if ( e.which !== 1 || $badge.data( 'clicked' ) ) { - return false; + // Do not return false (as that calls stopPropagation) + e.preventDefault(); + return; } $badge.data( 'clicked', true ); @@ -270,8 +272,8 @@ function initDesktop() { // Un-dim badge if loading failed $badge.removeClass( 'mw-echo-notifications-badge-dimmed' ); } ); - // Prevent default - return false; + // Prevent default. Do not return false (as that calls stopPropagation) + e.preventDefault(); } ); function pollForNotificationCountUpdates() { diff --git a/modules/ui/mw.echo.ui.BadgeLinkWidget.js b/modules/ui/mw.echo.ui.BadgeLinkWidget.js index ed1cf4c58..df7af5ed0 100644 --- a/modules/ui/mw.echo.ui.BadgeLinkWidget.js +++ b/modules/ui/mw.echo.ui.BadgeLinkWidget.js @@ -52,6 +52,18 @@ mw.echo.ui.BadgeLinkWidget.static.tagName = 'a'; + /** + * Overrides ButtonElement.prototype.onClick so that it doesn't call ev.stopPropagation. + * This ensures the dialog dismisses other open overlays e.g. ULS (See T295796 for more + * information). + * + * @inheritDoc + */ + mw.echo.ui.BadgeLinkWidget.prototype.onClick = function ( ev ) { + ev.preventDefault(); + this.emit( 'click' ); + }; + /** * Set the count labels for this button. *