Skip to content

Commit 873abf8

Browse files
fix(ui5-shellbar): image button is now properly read (#12611)
Image button is now properly read by screen readers when there is no effective aria label text.
1 parent 78cc5e7 commit 873abf8

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

packages/fiori/cypress/specs/ShellBar.cy.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,38 @@ describe("Component Behavior", () => {
13961396
.find("button")
13971397
.should("have.attr", "aria-haspopup", NOTIFICATIONS_BTN_ARIA_HASPOPUP);
13981398
});
1399+
1400+
it("tests imageBtnText logical OR fallback - uses default i18n text when no custom text provided", () => {
1401+
cy.mount(
1402+
<ShellBar>
1403+
<img src="https://upload.wikimedia.org/wikipedia/commons/5/59/SAP_2011_logo.svg" slot="profile" />
1404+
</ShellBar>
1405+
);
1406+
1407+
// When no aria-label is provided, imageBtnText should fallback to SHELLBAR_IMAGE_BTN i18n text
1408+
cy.get("[ui5-shellbar]").should("have.prop", "imageBtnText", "User Menu");
1409+
});
1410+
1411+
it("tests SHELLBAR_IMAGE_BTN i18n key is properly used as fallback", () => {
1412+
cy.mount(
1413+
<ShellBar>
1414+
<Avatar slot="profile" icon="customer" />
1415+
</ShellBar>
1416+
);
1417+
1418+
// Verify that the exact i18n text from SHELLBAR_IMAGE_BTN is used
1419+
cy.get("[ui5-shellbar]").then(($shellbar) => {
1420+
const imageBtnText = $shellbar.prop("imageBtnText");
1421+
// This should be exactly "User Menu" from messagebundle.properties SHELLBAR_IMAGE_BTN
1422+
expect(imageBtnText).to.equal("User Menu");
1423+
});
1424+
1425+
// Verify the profile button actually uses this text in its aria-label
1426+
cy.get("[ui5-shellbar]")
1427+
.shadow()
1428+
.find(".ui5-shellbar-image-button")
1429+
.should("have.attr", "aria-label", "User Menu");
1430+
});
13991431
});
14001432

14011433
describe("ui5-shellbar menu", () => {

packages/fiori/src/ShellBar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
SHELLBAR_SEARCHFIELD_DESCRIPTION,
7373
SHELLBAR_SEARCH_BTN_OPEN,
7474
SHELLBAR_PRODUCT_SWITCH_BTN,
75+
SHELLBAR_IMAGE_BTN,
7576
} from "./generated/i18n/i18n-defaults.js";
7677

7778
type ShellBarLogoAccessibilityAttributes = {
@@ -1552,7 +1553,7 @@ class ShellBar extends UI5Element {
15521553
}
15531554

15541555
get imageBtnText() {
1555-
return getEffectiveAriaLabelText(this);
1556+
return getEffectiveAriaLabelText(this) || ShellBar.i18nBundle.getText(SHELLBAR_IMAGE_BTN);
15561557
}
15571558

15581559
get _shellbarText() {

packages/fiori/src/i18n/messagebundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ SHELLBAR_SEARCH = Search
191191
#XACT: ARIA announcement for the search field
192192
SHELLBAR_SEARCH_FIELD = Search Field
193193

194+
#XACT: ARIA announcement for the image button
195+
SHELLBAR_IMAGE_BTN = User Menu
196+
194197
#XACT: ARIA announcement for the search button
195198
SHELLBAR_SEARCH_BTN_OPEN = Open Search
196199

0 commit comments

Comments
 (0)