Skip to content

Commit 7d6fdeb

Browse files
authored
feat(ui5-shellbar): add branding area accessibility attributes (#11238)
Enhance accessibility for the ShellBar component by adding support for custom accessibility attributes on the branding/primary title area. This allows developers to provide consistent screen reader announcements for menu buttons across different pages, regardless of the changing page title content. Fixes: #6826, #8708
1 parent 1d11709 commit 7d6fdeb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/fiori/src/ShellBar.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ type ShellBarLogoAccessibilityAttributes = {
7575
}
7676
type ShellBarProfileAccessibilityAttributes = Pick<AccessibilityAttributes, "name" | "expanded" | "hasPopup">;
7777
type ShellBarAreaAccessibilityAttributes = Pick<AccessibilityAttributes, "hasPopup" | "expanded">;
78+
type ShellBarBrandingAccessibilityAttributes = Pick<AccessibilityAttributes, "name">;
7879
type ShellBarAccessibilityAttributes = {
7980
logo?: ShellBarLogoAccessibilityAttributes
8081
notifications?: ShellBarAreaAccessibilityAttributes
8182
profile?: ShellBarProfileAccessibilityAttributes,
8283
product?: ShellBarAreaAccessibilityAttributes
8384
search?: ShellBarAreaAccessibilityAttributes
8485
overflow?: ShellBarAreaAccessibilityAttributes
86+
branding?: ShellBarBrandingAccessibilityAttributes
8587
};
8688

8789
type ShellBarNotificationsClickEventDetail = {
@@ -377,6 +379,7 @@ class ShellBar extends UI5Element {
377379
* - **product** - `product.expanded` and `product.hasPopup`.
378380
* - **search** - `search.hasPopup`.
379381
* - **overflow** - `overflow.expanded` and `overflow.hasPopup`.
382+
* - **branding** - `branding.name`.
380383
*
381384
* The accessibility attributes support the following values:
382385
*
@@ -1499,6 +1502,10 @@ class ShellBar extends UI5Element {
14991502
return ShellBar.i18nBundle.getText(SHELLBAR_OVERFLOW);
15001503
}
15011504

1505+
get _brandingText() {
1506+
return this.accessibilityAttributes.branding?.name || this.primaryTitle;
1507+
}
1508+
15021509
get hasContentItems() {
15031510
return this.contentItems.length > 0;
15041511
}
@@ -1598,6 +1605,12 @@ class ShellBar extends UI5Element {
15981605
expanded: overflowExpanded === undefined ? this._overflowPopoverExpanded : overflowExpanded,
15991606
},
16001607
},
1608+
branding: {
1609+
"title": this._brandingText,
1610+
"accessibilityAttributes": {
1611+
name: this.accessibilityAttributes.branding?.name,
1612+
},
1613+
},
16011614
};
16021615
}
16031616

packages/fiori/src/ShellBarTemplate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function ShellBarTemplate(this: ShellBar) {
2929
onClick={this._headerPress}
3030
aria-haspopup="menu"
3131
aria-expanded={this._menuPopoverExpanded}
32+
aria-label={this._brandingText}
3233
data-ui5-stable="menu"
3334
tabIndex={0}>
3435
{this.showLogoInMenuButton && (
@@ -290,7 +291,7 @@ function combinedLogo(this: ShellBar) {
290291
tabIndex={0}
291292
onKeyDown={this._logoKeydown}
292293
onKeyUp={this._logoKeyup}
293-
aria-label={this._logoAreaText}>
294+
aria-label={this.accessibilityAttributes.branding?.name || this._logoAreaText}>
294295
{this.hasLogo && (
295296
<span
296297
class="ui5-shellbar-logo"

0 commit comments

Comments
 (0)