Skip to content

Commit c597536

Browse files
authored
feat(ui5-toolbar): introduce overflowButtonAccessibleName property (#13416)
Adds a new overflowButtonAccessibleName public property that allows consumers to set a custom accessible name on the toolbar overflow button. When not set, the built-in translation for "Additional Options" is used as a fallback, preserving existing behavior. Related to: #11968
1 parent f7468e1 commit c597536

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

packages/main/cypress/specs/Toolbar.cy.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,3 +831,32 @@ describe("ToolbarButton", () => {
831831
});
832832
});
833833

834+
describe("Toolbar overflow button accessible name", () => {
835+
it("should use the default i18n accessible name when overflowButtonAccessibleName is not set", () => {
836+
cy.mount(
837+
<Toolbar>
838+
<ToolbarButton text="Add" icon="add" overflow-priority="AlwaysOverflow"></ToolbarButton>
839+
</Toolbar>
840+
);
841+
842+
cy.get("[ui5-toolbar]")
843+
.shadow()
844+
.find(".ui5-tb-overflow-btn")
845+
.should("not.have.class", "ui5-tb-overflow-btn-hidden")
846+
.should("have.attr", "accessible-name", "Additional Options");
847+
});
848+
849+
it("should use the custom accessible name when overflowButtonAccessibleName is set", () => {
850+
cy.mount(
851+
<Toolbar overflow-button-accessible-name="More actions for Opportunity 123">
852+
<ToolbarButton text="Add" icon="add" overflow-priority="AlwaysOverflow"></ToolbarButton>
853+
</Toolbar>
854+
);
855+
856+
cy.get("[ui5-toolbar]")
857+
.shadow()
858+
.find(".ui5-tb-overflow-btn")
859+
.should("not.have.class", "ui5-tb-overflow-btn-hidden")
860+
.should("have.attr", "accessible-name", "More actions for Opportunity 123");
861+
});
862+
});

packages/main/src/Toolbar.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ class Toolbar extends UI5Element {
134134
@property()
135135
accessibleNameRef?: string;
136136

137+
/**
138+
* Defines the accessible ARIA name of the overflow button of the component.
139+
*
140+
* **Note:** When not set, the built-in translation for "Additional Options" is used.
141+
* @default undefined
142+
* @public
143+
* @since 2.22.0
144+
*/
145+
@property()
146+
overflowButtonAccessibleName?: string;
147+
137148
/**
138149
* Defines the toolbar design.
139150
* @public
@@ -242,7 +253,7 @@ class Toolbar extends UI5Element {
242253
accessibleName: this.ariaLabelText,
243254
},
244255
overflowButton: {
245-
accessibleName: Toolbar.i18nBundle.getText(TOOLBAR_OVERFLOW_BUTTON_ARIA_LABEL),
256+
accessibleName: this.overflowButtonAccessibleName || Toolbar.i18nBundle.getText(TOOLBAR_OVERFLOW_BUTTON_ARIA_LABEL),
246257
tooltip: Toolbar.i18nBundle.getText(TOOLBAR_OVERFLOW_BUTTON_ARIA_LABEL),
247258
accessibilityAttributes: {
248259
expanded: this.popoverOpen,

packages/main/test/pages/Toolbar.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@
158158

159159
<br /><br />
160160

161+
<ui5-title level="H3">Toolbar with custom overflow button accessible name</ui5-title>
162+
<br />
163+
164+
<section>
165+
<ui5-toolbar overflow-button-accessible-name="More actions for Opportunity 123">
166+
<ui5-toolbar-button icon="add" text="Left 1 (long)" width="150px"></ui5-toolbar-button>
167+
<ui5-toolbar-button icon="decline" text="Left 2"></ui5-toolbar-button>
168+
<ui5-toolbar-button icon="employee" text="Call me later" overflow-priority="AlwaysOverflow"></ui5-toolbar-button>
169+
</ui5-toolbar>
170+
</section>
171+
172+
<br /><br />
173+
161174
<ui5-title level="H3">Toolbar with "NeverOverflow" overflow priority item (divided visually by internal
162175
separator)</ui5-title>
163176
<br />

0 commit comments

Comments
 (0)