Skip to content

feat(ui5-shellbar): accessibility enhancements #11238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/fiori/src/ShellBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ type ShellBarLogoAccessibilityAttributes = {
}
type ShellBarProfileAccessibilityAttributes = Pick<AccessibilityAttributes, "name" | "expanded" | "hasPopup">;
type ShellBarAreaAccessibilityAttributes = Pick<AccessibilityAttributes, "hasPopup" | "expanded">;
type ShellBarBrandingAccessibilityAttributes = Pick<AccessibilityAttributes, "name" | "role">;
type ShellBarAccessibilityAttributes = {
logo?: ShellBarLogoAccessibilityAttributes
notifications?: ShellBarAreaAccessibilityAttributes
profile?: ShellBarProfileAccessibilityAttributes,
product?: ShellBarAreaAccessibilityAttributes
search?: ShellBarAreaAccessibilityAttributes
overflow?: ShellBarAreaAccessibilityAttributes
branding?: ShellBarBrandingAccessibilityAttributes
};

type ShellBarNotificationsClickEventDetail = {
Expand Down Expand Up @@ -351,6 +353,7 @@ class ShellBar extends UI5Element {
* - **product** - `product.expanded` and `product.hasPopup`.
* - **search** - `search.hasPopup`.
* - **overflow** - `overflow.expanded` and `overflow.hasPopup`.
* - **branding** - `branding.role` and `branding.name`.
*
* The accessibility attributes support the following values:
*
Expand Down Expand Up @@ -1422,6 +1425,10 @@ class ShellBar extends UI5Element {
return ShellBar.i18nBundle.getText(SHELLBAR_OVERFLOW);
}

get _brandingText() {
return this.accessibilityAttributes.branding?.name || this.primaryTitle;
}

get hasContentItems() {
return this.contentItems.length > 0;
}
Expand Down Expand Up @@ -1520,6 +1527,13 @@ class ShellBar extends UI5Element {
hasPopup: this.accessibilityAttributes.overflow?.hasPopup || "menu" as const,
expanded: overflowExpanded === undefined ? this._overflowPopoverExpanded : overflowExpanded,
},
branding: {
"title": this._brandingText,
"accessibilityAttributes": {
role: this.accessibilityAttributes.branding?.role,
Copy link
Preview

Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branding 'role' attribute in the ShellBar configuration does not have a fallback if 'accessibilityAttributes.branding?.role' is undefined. Consider providing a default value (e.g. using a value similar to 'this.accLogoRole') to avoid potential undefined behavior.

Suggested change
role: this.accessibilityAttributes.branding?.role,
role: this.accessibilityAttributes.branding?.role || this.accLogoRole,

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

name: this.accessibilityAttributes.branding?.name,
},
},
},
};
}
Expand Down
5 changes: 3 additions & 2 deletions packages/fiori/src/ShellBarTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function ShellBarTemplate(this: ShellBar) {
onClick={this._headerPress}
aria-haspopup="menu"
aria-expanded={this._menuPopoverExpanded}
aria-label={this.accessibilityAttributes.branding?.name || this.primaryTitle}
data-ui5-stable="menu"
tabIndex={0}>
{this.showLogoInMenuButton && (
Expand Down Expand Up @@ -278,13 +279,13 @@ function singleLogo(this: ShellBar) {
function combinedLogo(this: ShellBar) {
return (
<div
role={this.accLogoRole}
role={this.accessibilityAttributes.branding?.role || this.accLogoRole}
class="ui5-shellbar-logo-area"
onClick={this._logoPress}
tabIndex={0}
onKeyDown={this._logoKeydown}
onKeyUp={this._logoKeyup}
aria-label={this._logoAreaText}>
aria-label={this.accessibilityAttributes.branding?.name || this._logoAreaText}>
{this.hasLogo && (
<span
class="ui5-shellbar-logo"
Expand Down
Loading