From 7880cc18950b209deca5e76312b933ccb6fd3df1 Mon Sep 17 00:00:00 2001 From: Nicholas Ray Date: Thu, 27 May 2021 18:44:42 -0600 Subject: [PATCH] Make talk page notification use `link-class`, `id` and don't set `class` Before this commit, setting: ``` $wgVectorConsolidateUserLinks = [ 'logged_in' => true ]; ``` would result in an orange talk notification that had missing or incorrect attributes (`#ca-mytalk` instead of `#pt-mytalk` and missing the `title` and `accesskey` attributes) when visiting modern Vector with a talk notification visible. The notification's html looked like: ```
  • You have a new Talk page message
  • ``` The `pt-mytalk` id is important for echo to remove the notification [1]. The title and accesskey are important for accessibility reasons. This commit corrects that by setting a `link-class`, setting an explicit `id`, and NOT setting a `class` key. This results in html that is correct in both modern and legacy Vector: ```
  • You have a new Talk page message
  • ``` [1] https://github.com/wikimedia/mediawiki-extensions-Echo/blob/67bf58a4896f86f4dcf034ef1fe1458939a6a91b/modules/ext.echo.init.js#L172 Bug: T274428 Change-Id: I5afc74992ad3153ac32df65ccf5fd03b469f05fb --- includes/EchoHooks.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/EchoHooks.php b/includes/EchoHooks.php index 8a25d26e1..bc717ccbf 100644 --- a/includes/EchoHooks.php +++ b/includes/EchoHooks.php @@ -1131,13 +1131,17 @@ class EchoHooks implements RecentChange_saveHook { ->getHookContainer()->run( 'BeforeDisplayOrangeAlert', [ $user, $title ] ) ) { // Move `mytalk` from `user-menu` to `notifications`. - $links['notifications']['mytalk'] = array_merge( - $links['user-menu']['mytalk'], - [ - 'text' => $skinTemplate->msg( 'echo-new-messages' )->text(), - 'class' => [ 'mw-echo-alert' ] - ] - ); + $links['notifications']['mytalk'] = [ + 'href' => $links['user-menu']['mytalk']['href'], + 'text' => $skinTemplate->msg( 'echo-new-messages' ), + + 'active' => $links['user-menu']['mytalk']['active'], + 'exists' => $links['user-menu']['mytalk']['exists'], + 'link-class' => [ 'mw-echo-alert' ], + // Id of `pt-mytalk` is important for Linker to set the `title` and + // `accesskey` attributes. + 'id' => 'pt-mytalk', + ]; unset( $links['user-menu']['mytalk'] ); }