Skip to content

Commit 1998db4

Browse files
niyapndeshev
andauthored
fix(ui5-wizard): announce active step when navigating via a button (#4298) (#4420)
* fix(ui5-wizard) announce active step when navigating via a button (#4298) * Announce active step on navigation via button * Clean * Beautify * Adjust announcement, add role 'region' * Announce only the step title as a region * Add tests * Fix test * Add 'step' to the announcement * fix failing tests Co-authored-by: Nikolay Deshev <nikolay.deshev@sap.com>
1 parent 58e9249 commit 1998db4

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/fiori/src/Wizard.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
?hidden="{{disabled}}"
3232
?selected="{{selected}}"
3333
?stretch="{{stretch}}"
34+
aria-label="{{stepContentAriaLabel}}"
35+
role="region"
3436
data-ui5-content-item-ref-id="{{_id}}">
3537
<slot name="{{this._individualSlot}}"></slot>
3638
</div>

packages/fiori/src/Wizard.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,9 @@ class Wizard extends UI5Element {
682682
const lastEnabledStepIndex = this.getLastEnabledStepIndex();
683683

684684
return this.steps.map((step, idx) => {
685+
const pos = idx + 1;
685686
step.stretch = idx === lastEnabledStepIndex;
687+
step.stepContentAriaLabel = (step.heading ? `${this.navStepDefaultHeading} ${pos} ${step.heading}` : `${pos}`).trim();
686688
return step;
687689
});
688690
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ describe("Wizard general interaction", () => {
2020
const wizRoot = wiz.shadow$(".ui5-wiz-root");
2121
const wizNav = wiz.shadow$(".ui5-wiz-nav");
2222
const wizList = wiz.shadow$(".ui5-wiz-nav-list");
23+
const wizStep = wiz.shadow$(".ui5-wiz-content-item");
2324

2425
const wizRootText = "Wizard";
2526
const wizNavText = "Wizard Progress Bar";
2627
const wizListText = "Wizard Steps";
2728

29+
const step1InHeader = wiz.shadow$(`[data-ui5-index="1"]`)
30+
2831
assert.strictEqual(wizRoot.getAttribute("role"), "region",
2932
"Wizard has role set.");
3033
assert.strictEqual(wizRoot.getAttribute("aria-label"), wizRootText,
@@ -37,6 +40,10 @@ describe("Wizard general interaction", () => {
3740
"Wizard list has aria-controls set.");
3841
assert.strictEqual(wizList.getAttribute("aria-label"), wizListText,
3942
"Wizard list has aria-label set.");
43+
assert.strictEqual(wizStep.getAttribute("role"), "region",
44+
"Step has role 'region'");
45+
assert.strictEqual(wizStep.getAttribute("aria-label"), `Step 1 ${step1InHeader.getProperty("heading")}`,
46+
"Step has aria-label set to the number of the step and its title.");
4047
});
4148

4249
it("move to next step by API", () => {

0 commit comments

Comments
 (0)