diff --git a/packages/pluggableWidgets/switch-web/CHANGELOG.md b/packages/pluggableWidgets/switch-web/CHANGELOG.md index 6fd06fa527..4e9bd6376c 100644 --- a/packages/pluggableWidgets/switch-web/CHANGELOG.md +++ b/packages/pluggableWidgets/switch-web/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +- Improved accessibility and input handling. Clicking the label now toggles the switch. + ## [4.2.2] - 2024-08-28 ### Changed diff --git a/packages/pluggableWidgets/switch-web/package.json b/packages/pluggableWidgets/switch-web/package.json index 3166fca0c4..314ef2d04f 100644 --- a/packages/pluggableWidgets/switch-web/package.json +++ b/packages/pluggableWidgets/switch-web/package.json @@ -1,7 +1,7 @@ { "name": "@mendix/switch-web", "widgetName": "Switch", - "version": "4.2.2", + "version": "4.3.0", "description": "Toggle a boolean attribute", "copyright": "© Mendix Technology BV 2025. All rights reserved.", "license": "Apache-2.0", diff --git a/packages/pluggableWidgets/switch-web/src/__tests__/Switch.spec.tsx b/packages/pluggableWidgets/switch-web/src/__tests__/Switch.spec.tsx index 3175adb4a1..5951a4cbd2 100644 --- a/packages/pluggableWidgets/switch-web/src/__tests__/Switch.spec.tsx +++ b/packages/pluggableWidgets/switch-web/src/__tests__/Switch.spec.tsx @@ -99,7 +99,7 @@ describe("Switch", () => { const { container } = renderSwitch(props); const wrapper = container.querySelector(".widget-switch-btn-wrapper"); expect(wrapper?.classList.contains("disabled")).toBe(false); - expect(wrapper?.getAttribute("aria-readonly")).toBe("false"); + expect(wrapper?.getAttribute("aria-disabled")).toBe("false"); }); it("invokes action on click", () => { @@ -173,7 +173,7 @@ describe("Switch", () => { const { container } = renderSwitch(props); const wrapper = container.querySelector(".widget-switch-btn-wrapper"); expect(wrapper?.classList.contains("disabled")).toBe(true); - expect(wrapper?.getAttribute("aria-readonly")).toBe("true"); + expect(wrapper?.getAttribute("aria-disabled")).toBe("true"); }); it("shouldn't invoke action", () => { diff --git a/packages/pluggableWidgets/switch-web/src/__tests__/__snapshots__/Switch.spec.tsx.snap b/packages/pluggableWidgets/switch-web/src/__tests__/__snapshots__/Switch.spec.tsx.snap index dab78412e6..5cd9046782 100644 --- a/packages/pluggableWidgets/switch-web/src/__tests__/__snapshots__/Switch.spec.tsx.snap +++ b/packages/pluggableWidgets/switch-web/src/__tests__/__snapshots__/Switch.spec.tsx.snap @@ -5,12 +5,20 @@ exports[`Switch with editable value renders the structure correctly 1`] = `
+
@@ -27,12 +35,21 @@ exports[`Switch with readonly value renders the structure correctly 1`] = `
+
diff --git a/packages/pluggableWidgets/switch-web/src/components/Switch.tsx b/packages/pluggableWidgets/switch-web/src/components/Switch.tsx index 15b8d05919..71cee5ac72 100644 --- a/packages/pluggableWidgets/switch-web/src/components/Switch.tsx +++ b/packages/pluggableWidgets/switch-web/src/components/Switch.tsx @@ -14,8 +14,19 @@ export interface SwitchProps extends Pick -