From b6f5272d7fd633a873ae30b53bd1d06b56d6b7da Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Thu, 4 May 2023 16:22:44 -0700 Subject: [PATCH 1/4] Address ToggleSwitch a11y feedback --- src/ToggleSwitch/ToggleSwitch.tsx | 7 ++-- src/__tests__/ToggleSwitch.test.tsx | 37 ++++++++++++----- .../__snapshots__/ToggleSwitch.test.tsx.snap | 41 ++++++------------- 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/ToggleSwitch/ToggleSwitch.tsx b/src/ToggleSwitch/ToggleSwitch.tsx index 851757d9bab..01422957897 100644 --- a/src/ToggleSwitch/ToggleSwitch.tsx +++ b/src/ToggleSwitch/ToggleSwitch.tsx @@ -254,7 +254,8 @@ const ToggleSwitch: React.FC> = ({ fontSize={size === 'small' ? 0 : 1} mx={2} aria-hidden="true" - sx={{position: 'relative'}} + sx={{position: 'relative', cursor: 'pointer'}} + onClick={handleToggleClick} > On @@ -267,13 +268,11 @@ const ToggleSwitch: React.FC> = ({ onClick={handleToggleClick} aria-labelledby={ariaLabelledby} aria-describedby={ariaDescribedby} - aria-checked={isOn} - role="switch" + aria-pressed={isOn} checked={isOn} size={size} disabled={!acceptsInteraction} > - {isOn ? 'On' : 'Off'}