Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions packages/main/cypress/specs/Switch.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe("General accesibility attributes", () => {
.ui5SwitchCheckAttributeInShadowDomRoot("role", "switch");

cy.get("@switch")
.ui5SwitchCheckAttributeInShadowDomRoot("aria-label", `${geoLocationDescr} No`);
.ui5SwitchCheckAttributeInShadowDomRoot("aria-label", geoLocationDescr);

});

Expand All @@ -127,7 +127,7 @@ describe("General accesibility attributes", () => {
.ui5SwitchCheckAttributeInShadowDomRoot("role", "switch");

cy.get("@switch")
.ui5SwitchCheckAttributeInShadowDomRoot("aria-label", `${gpsLocationDescr} No`);
.ui5SwitchCheckAttributeInShadowDomRoot("aria-label", gpsLocationDescr);
});

it("Should set correct correct tooltip on the root", () => {
Expand All @@ -137,11 +137,13 @@ describe("General accesibility attributes", () => {
.ui5SwitchCheckAttributeInShadowDomRoot("title", gpsLocationDescr);
});

it("Should set correct attribute 'aria-label' when 'text-on' and 'text-off' attributes aren't set", () => {
it("Should not have 'aria-label' attribute when 'text-on' and 'text-off' attributes aren't set", () => {
cy.mount(<Switch></Switch>);

cy.get("[ui5-switch]")
.ui5SwitchCheckAttributeInShadowDomRoot("aria-label", "");
.shadow()
.find(".ui5-switch-root")
.should("not.have.attr", "aria-label");
});

it("Should propagate 'required' attribute properly on the root", () => {
Expand Down
18 changes: 4 additions & 14 deletions packages/main/src/Switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import "@ui5/webcomponents-icons/dist/accept.js";
import "@ui5/webcomponents-icons/dist/decline.js";
import "@ui5/webcomponents-icons/dist/less.js";
import SwitchDesign from "./types/SwitchDesign.js";
import { FORM_CHECKABLE_REQUIRED } from "./generated/i18n/i18n-defaults.js";
import {
FORM_CHECKABLE_REQUIRED,
} from "./generated/i18n/i18n-defaults.js";

// Template
import SwitchTemplate from "./SwitchTemplate.js";
Expand Down Expand Up @@ -307,20 +309,8 @@ class Switch extends UI5Element implements IFormInputElement {
return this.disabled ? "true" : undefined;
}

get accessibilityOnText() {
return this._textOn;
}

get accessibilityOffText() {
return this._textOff;
}

get hiddenText() {
return this.checked ? this.accessibilityOnText : this.accessibilityOffText;
}

get ariaLabelText() {
return [getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this), this.hiddenText].join(" ").trim();
return getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || undefined;
}
}

Expand Down
Loading