Skip to content

Commit f199a19

Browse files
committed
feat(ui5-shellbar): add accessibility enhancements
1 parent d599dab commit f199a19

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/fiori/src/ShellBar.ts

+14
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" | "role">;
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 = {
@@ -351,6 +353,7 @@ class ShellBar extends UI5Element {
351353
* - **product** - `product.expanded` and `product.hasPopup`.
352354
* - **search** - `search.hasPopup`.
353355
* - **overflow** - `overflow.expanded` and `overflow.hasPopup`.
356+
* - **branding** - `branding.role` and `branding.name`.
354357
*
355358
* The accessibility attributes support the following values:
356359
*
@@ -1422,6 +1425,10 @@ class ShellBar extends UI5Element {
14221425
return ShellBar.i18nBundle.getText(SHELLBAR_OVERFLOW);
14231426
}
14241427

1428+
get _brandingText() {
1429+
return this.accessibilityAttributes.branding?.name || this.primaryTitle;
1430+
}
1431+
14251432
get hasContentItems() {
14261433
return this.contentItems.length > 0;
14271434
}
@@ -1520,6 +1527,13 @@ class ShellBar extends UI5Element {
15201527
hasPopup: this.accessibilityAttributes.overflow?.hasPopup || "menu" as const,
15211528
expanded: overflowExpanded === undefined ? this._overflowPopoverExpanded : overflowExpanded,
15221529
},
1530+
branding: {
1531+
"title": this._brandingText,
1532+
"accessibilityAttributes": {
1533+
role: this.accessibilityAttributes.branding?.role,
1534+
name: this.accessibilityAttributes.branding?.name,
1535+
},
1536+
},
15231537
},
15241538
};
15251539
}

packages/fiori/src/ShellBarTemplate.tsx

+3-2
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.accessibilityAttributes.branding?.name || this.primaryTitle}
3233
data-ui5-stable="menu"
3334
tabIndex={0}>
3435
{this.showLogoInMenuButton && (
@@ -278,13 +279,13 @@ function singleLogo(this: ShellBar) {
278279
function combinedLogo(this: ShellBar) {
279280
return (
280281
<div
281-
role={this.accLogoRole}
282+
role={this.accessibilityAttributes.branding?.role || this.accLogoRole}
282283
class="ui5-shellbar-logo-area"
283284
onClick={this._logoPress}
284285
tabIndex={0}
285286
onKeyDown={this._logoKeydown}
286287
onKeyUp={this._logoKeyup}
287-
aria-label={this._logoAreaText}>
288+
aria-label={this.accessibilityAttributes.branding?.name || this._logoAreaText}>
288289
{this.hasLogo && (
289290
<span
290291
class="ui5-shellbar-logo"

0 commit comments

Comments
 (0)