Skip to content

Commit

Permalink
feat(ui5-shellbar): introduce accessibilityTexts property (#4377)
Browse files Browse the repository at this point in the history
New property from type Object, called accessibilityTexts is introduced to allow customization of some internal parts of the ShellBar web component via stable API. Currently the only thing available on the object is the profileButtonTitle to define the profile button tooltip, showing up on hover.

Fixes: #4009
  • Loading branch information
ilhan007 authored Nov 23, 2021
1 parent 9abdaba commit f762e76
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/fiori/src/ShellBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ const metadata = {
type: Boolean,
},

/**
* An object of strings that defines several additional accessibility texts
* for even further customization.
*
* It supports the following fields:
* - <code>profileButtonTitle</code>: defines the tooltip for the profile button
*
* @type {object}
* @public
* @since 1.1.0
*/
accessibilityTexts: {
type: Object,
},

/**
* @private
*/
Expand Down Expand Up @@ -1129,7 +1144,7 @@ class ShellBar extends UI5Element {
}

get _profileText() {
return ShellBar.i18nBundle.getText(SHELLBAR_PROFILE);
return this.accessibilityTexts.profileButtonTitle || ShellBar.i18nBundle.getText(SHELLBAR_PROFILE);
}

get _productsText() {
Expand Down
8 changes: 8 additions & 0 deletions packages/fiori/test/pages/ShellBar.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ <h3>ShellBar in Compact</h3>

<ui5-toast id="wcToastTC">Custom Action Fired</ui5-toast>

<ui5-shellbar id="sbAcc">
<ui5-avatar slot="profile" icon="customer"></ui5-avatar>
</ui5-shellbar>

<script>
mySearch.addEventListener("suggestionItemSelect", function (event) {
 console.log(event);
Expand Down Expand Up @@ -294,6 +298,10 @@ <h3>ShellBar in Compact</h3>
window["press-input3"].value = event.target.id;
});
});

sbAcc.accessibilityTexts = {
profileButtonTitle: "John Dow",
};
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions packages/fiori/test/specs/ShellBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ describe("Component Behavior", () => {
await browser.url(`http://localhost:${PORT}/test-resources/pages/ShellBar.html`);
});

describe("Аccessibility", () => {
it("tests accessibilityTexts property", async () => {
const PROFILE_BTN_CUSTOM_TOOLTIP = "John Dow";
const sb = await browser.$("#sbAcc");

assert.strictEqual(await sb.getProperty("_profileText"), PROFILE_BTN_CUSTOM_TOOLTIP,
"Profile button tooltip can be cutomized.");
});
});

describe("ui5-shellbar menu", () => {
it("tests close on content click", async () => {
Expand Down

0 comments on commit f762e76

Please sign in to comment.