From 4c59d4ce8104f58190b9e0bf2d78703532b0d90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 11 May 2021 17:28:10 +0200 Subject: [PATCH] MOBILE-3753 menu: Add context to main menu badges --- src/addons/messages/services/handlers/mainmenu.ts | 1 + src/addons/notifications/services/handlers/mainmenu.ts | 1 + src/core/features/mainmenu/pages/menu/menu.html | 9 ++++++--- src/core/features/mainmenu/pages/more/more.html | 6 +++++- src/core/features/mainmenu/services/mainmenu-delegate.ts | 5 +++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/addons/messages/services/handlers/mainmenu.ts b/src/addons/messages/services/handlers/mainmenu.ts index 4461ee4f9..2f8021415 100644 --- a/src/addons/messages/services/handlers/mainmenu.ts +++ b/src/addons/messages/services/handlers/mainmenu.ts @@ -47,6 +47,7 @@ export class AddonMessagesMainMenuHandlerService implements CoreMainMenuHandler, class: 'addon-messages-handler', showBadge: true, // Do not check isMessageCountEnabled because we'll use fallback it not enabled. badge: '', + badgeA11yText: 'addon.messages.unreadconversations', loading: true, }; diff --git a/src/addons/notifications/services/handlers/mainmenu.ts b/src/addons/notifications/services/handlers/mainmenu.ts index dbf5aeb1e..5cb4584d2 100644 --- a/src/addons/notifications/services/handlers/mainmenu.ts +++ b/src/addons/notifications/services/handlers/mainmenu.ts @@ -41,6 +41,7 @@ export class AddonNotificationsMainMenuHandlerService implements CoreMainMenuHan class: 'addon-notifications-handler', showBadge: true, badge: '', + badgeA11yText: 'addon.notifications.unreadnotification', loading: true, }; diff --git a/src/core/features/mainmenu/pages/menu/menu.html b/src/core/features/mainmenu/pages/menu/menu.html index 1b2d09b25..ba8099d71 100644 --- a/src/core/features/mainmenu/pages/menu/menu.html +++ b/src/core/features/mainmenu/pages/menu/menu.html @@ -16,11 +16,14 @@ [selected]="tab.page === selectedTab" [tabindex]="selectedTab == tab.page ? 0 : -1" [attr.aria-controls]="tab.id" - [attr.aria-label]="tab.title | translate" > - {{ tab.badge }} + + {{ tab.title | translate }} + + {{ tab.badgeA11yText | translate: {$a : tab.badge } }} + + {{ 'core.more' | translate }} diff --git a/src/core/features/mainmenu/pages/more/more.html b/src/core/features/mainmenu/pages/more/more.html index 79b029c4e..7811f7d7a 100644 --- a/src/core/features/mainmenu/pages/more/more.html +++ b/src/core/features/mainmenu/pages/more/more.html @@ -30,8 +30,12 @@

{{ handler.title | translate}}

- {{handler.badge}} + + + {{ handler.badgeA11yText | translate: {$a : handler.badge } }} + diff --git a/src/core/features/mainmenu/services/mainmenu-delegate.ts b/src/core/features/mainmenu/services/mainmenu-delegate.ts index 862bb5b55..998550f49 100644 --- a/src/core/features/mainmenu/services/mainmenu-delegate.ts +++ b/src/core/features/mainmenu/services/mainmenu-delegate.ts @@ -65,6 +65,11 @@ export interface CoreMainMenuHandlerData { */ badge?: string; + /** + * Accessibility text to add on the badge. Only used if showBadge is true. + */ + badgeA11yText?: string; + /** * If true, the badge number is being loaded. Only used if showBadge is true. */