Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-wizard): disabled steps are no longer clickable #9706

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/fiori/src/Wizard.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
._wizardTabAccInfo="{{accInfo}}"
data-ui5-content-ref-id="{{this.refStepId}}"
data-ui5-index="{{pos}}"
_tab-index="{{tabIndex}}"
@ui5-selection-change-requested="{{../onSelectionChangeRequested}}"
@ui5-focused="{{../onStepInHeaderFocused}}"
@click="{{../_onGroupedTabClick}}"
Expand Down
8 changes: 5 additions & 3 deletions packages/fiori/src/Wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ type StepInfo = {
pos: number,
accInfo: AccessibilityInformation,
refStepId: string,
tabIndex: string,
styles: object,
}

Expand Down Expand Up @@ -413,6 +412,10 @@ class Wizard extends UI5Element {

// Place for improvement: If the selected step is not the first, enable all the prior steps
this.selectedStepIndex = this.getSelectedStepIndex();

if (this.selectedStep && this.stepsInHeaderDOM.length) {
this._itemNavigation.setCurrentItem(this.stepsInHeaderDOM.find(el => el.selected) as WizardTab);
}
}

/**
Expand Down Expand Up @@ -811,7 +814,7 @@ class Wizard extends UI5Element {
}

get enabledStepsInHeaderDOM() {
return this.stepsInHeaderDOM;
return this.stepsInHeaderDOM.filter(step => !step.disabled);
}

get navAriaRoleDescription() {
Expand Down Expand Up @@ -902,7 +905,6 @@ class Wizard extends UI5Element {
pos,
accInfo,
refStepId: step._id,
tabIndex: this.selectedStepIndex === idx ? "0" : "-1",
styles: {
zIndex: isAfterCurrent ? --inintialZIndex : 1,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/src/WizardTab.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="ui5-wiz-step-root"
role="listitem"
tabindex="{{tabIndex}}"
tabindex="{{effectiveTabIndex}}"
aria-current="{{accInfo.ariaCurrent}}"
aria-setsize="{{accInfo.ariaSetsize}}"
aria-posinset="{{accInfo.ariaPosinset}}"
Expand Down
16 changes: 12 additions & 4 deletions packages/fiori/src/WizardTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,22 @@ class WizardTab extends UI5Element implements ITabbable {
this.fireEvent("focused");
}

get tabIndex() {
return Number(this.forcedTabIndex);
}

get hasTexts() {
return this.titleText || this.subtitleText;
}

get effectiveTabIndex() {
if (this.disabled) {
return;
}

if (this.selected || this.forcedTabIndex === "0") {
return "0";
}

return "-1";
}

get accInfo() {
return {
"ariaSetsize": this._wizardTabAccInfo && this._wizardTabAccInfo.ariaSetsize,
Expand Down
13 changes: 13 additions & 0 deletions packages/fiori/test/specs/Wizard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ describe("Wizard general interaction", () => {
"Step has aria-label set to the number of the step and its title.");
});

it("Disabled step should not be interactive", async () => {
const wiz = await $("#wizTest");
const disabledStep = await wiz.shadow$(`[data-ui5-index="2"]`);

await disabledStep.click();

const isTabActiveElement = await browser.executeAsync((done) => {
done(document.activeElement.shadowRoot.activeElement === document.querySelector("#wizTest").shadowRoot.querySelector("[data-ui5-index='2']"));
});

assert.notOk(isTabActiveElement, "Second tab should not be active element");
});

it("move to next step by API", async () => {
const wiz = await browser.$("#wizTest");
const btnToStep2 = await browser.$("#toStep2");
Expand Down
Loading