Skip to content

Commit 426e6c0

Browse files
committed
feat(ui5-shellbar): introduce accessibilityTexts property (#4377)
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
1 parent 82894cc commit 426e6c0

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

packages/fiori/src/ShellBar.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ const metadata = {
109109
type: Boolean,
110110
},
111111

112+
/**
113+
* An object of strings that defines several additional accessibility texts
114+
* for even further customization.
115+
*
116+
* It supports the following fields:
117+
* - <code>profileButtonTitle</code>: defines the tooltip for the profile button
118+
*
119+
* @type {object}
120+
* @public
121+
* @since 1.1.0
122+
*/
123+
accessibilityTexts: {
124+
type: Object,
125+
},
126+
112127
/**
113128
* @private
114129
*/
@@ -1021,7 +1036,7 @@ class ShellBar extends UI5Element {
10211036
}
10221037

10231038
get _profileText() {
1024-
return this.i18nBundle.getText(SHELLBAR_PROFILE);
1039+
return this.accessibilityTexts.profileButtonTitle || this.i18nBundle.getText(SHELLBAR_PROFILE);
10251040
}
10261041

10271042
get _productsText() {

packages/fiori/test/pages/ShellBar.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ <h3>ShellBar in Compact</h3>
225225
<ui5-shellbar-item icon="discussion" count="2" id="test-invalidation-item"/>
226226
</ui5-shellbar>
227227

228+
<ui5-shellbar id="sbAcc">
229+
<ui5-avatar slot="profile" icon="customer"></ui5-avatar>
230+
</ui5-shellbar>
231+
228232
<script>
229233
mySearch.addEventListener("suggestionItemSelect", function (event) {
230234
 console.log(event);
@@ -288,6 +292,10 @@ <h3>ShellBar in Compact</h3>
288292
window["custom-item-popover"].openBy(event.detail.targetRef);
289293
});
290294
});
295+
296+
sbAcc.accessibilityTexts = {
297+
profileButtonTitle: "John Dow",
298+
};
291299
</script>
292300
</body>
293301
</html>

packages/fiori/test/specs/ShellBar.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ const getCustomActionProp = (id, pos, prop) => {
2525
describe("Component Behavior", () => {
2626
browser.url("http://localhost:8081/test-resources/pages/ShellBar.html");
2727

28+
describe("Аccessibility", () => {
29+
it("tests accessibilityTexts property", async () => {
30+
const PROFILE_BTN_CUSTOM_TOOLTIP = "John Dow";
31+
const sb = await browser.$("#sbAcc");
32+
33+
assert.strictEqual(await sb.getProperty("_profileText"), PROFILE_BTN_CUSTOM_TOOLTIP,
34+
"Profile button tooltip can be cutomized.");
35+
});
36+
});
37+
38+
describe("ui5-shellbar menu", () => {
39+
it("tests close on content click", async () => {
40+
const primaryTitle = await browser.$("#shellbar").shadow$(".ui5-shellbar-menu-button");
41+
const staticAreaItemClassName = await browser.getStaticAreaItemClassName("#shellbar")
42+
const menuPopover = await browser.$(`.${staticAreaItemClassName}`).shadow$(".ui5-shellbar-menu-popover");
43+
const firstMenuItem = await menuPopover.$("ui5-list > ui5-li");
44+
45+
await primaryTitle.click();
46+
await firstMenuItem.click();
47+
48+
assert.strictEqual(await menuPopover.getProperty("opened"), false, "Count property propagates to ui5-button");
49+
});
50+
});
51+
52+
2853
describe("ui5-shellbar-item", () => {
2954
it("tests count property", () => {
3055
const shellbar = browser.$("#shellbarwithitems");

0 commit comments

Comments
 (0)