From 8c2c58cf044dd4f995c48b6aeb079ccbb59d5ec3 Mon Sep 17 00:00:00 2001 From: Inbal Tish Date: Wed, 4 Dec 2024 14:24:48 +0200 Subject: [PATCH 1/5] Switch - fix accessibility value by moving to accessibilityLabel that reads "on/off" for current state --- demo/src/screens/componentScreens/SwitchScreen.tsx | 4 +++- src/components/switch/index.tsx | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/demo/src/screens/componentScreens/SwitchScreen.tsx b/demo/src/screens/componentScreens/SwitchScreen.tsx index 74cd2ad064..cd64541da2 100644 --- a/demo/src/screens/componentScreens/SwitchScreen.tsx +++ b/demo/src/screens/componentScreens/SwitchScreen.tsx @@ -15,7 +15,9 @@ class SwitchScreen extends Component { return ( - this.setState({value1})} style={{marginBottom: 20}}/> + this.setState({value1})} style={{marginBottom: 20}}/> + this.setState({value2})} style={{marginBottom: 20}}/> + { getAccessibilityProps() { const {disabled, value} = this.props; - return { accessible: true, accessibilityRole: 'switch', + accessibilityLabel: value ? 'on' : 'off', accessibilityState: { disabled, checked: value ? 'checked' : 'unchecked' - }, - accessibilityValue: {text: value ? '1' : '0'} + } }; } From 1c5c272a3b8f98df11a9b16520938bd7a19f59df Mon Sep 17 00:00:00 2001 From: Inbal Tish Date: Wed, 4 Dec 2024 14:29:37 +0200 Subject: [PATCH 2/5] fix driver --- src/components/switch/switch.driver.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/switch/switch.driver.ts b/src/components/switch/switch.driver.ts index 836b81a805..9dfee60c83 100644 --- a/src/components/switch/switch.driver.ts +++ b/src/components/switch/switch.driver.ts @@ -6,9 +6,9 @@ export const SwitchDriver = (props: ComponentProps) => { const driver = usePressableDriver(useComponentDriver(props)); const getStyle = () => driver.getElement().props.style as ViewStyle; - const getAccessibilityValue = () => driver.getElement().props.accessibilityValue?.text === '1'; + const getAccessibilityValue = () => driver.getElement().props.accessibilityLabel === 'on'; const isDisabled = () => driver.getElement().props.accessibilityState?.disabled === true; - const isChecked = () => driver.getElement().props.accessibilityValue?.text === '1'; + const isChecked = () => driver.getElement().props.accessibilityLabel === 'on'; return {...driver, getStyle, getAccessibilityValue, isDisabled, isChecked}; }; From 55f542362b129c37a27a32ba2a979530465569a4 Mon Sep 17 00:00:00 2001 From: Inbal Tish Date: Sun, 8 Dec 2024 12:40:27 +0200 Subject: [PATCH 3/5] revert on/off change --- src/components/switch/index.tsx | 2 +- src/components/switch/switch.driver.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/switch/index.tsx b/src/components/switch/index.tsx index 72afba6174..8e982de92f 100644 --- a/src/components/switch/index.tsx +++ b/src/components/switch/index.tsx @@ -86,7 +86,7 @@ class Switch extends Component { return { accessible: true, accessibilityRole: 'switch', - accessibilityLabel: value ? 'on' : 'off', + accessibilityLabel: value ? '1' : '0', accessibilityState: { disabled, checked: value ? 'checked' : 'unchecked' diff --git a/src/components/switch/switch.driver.ts b/src/components/switch/switch.driver.ts index 9dfee60c83..9ff2a3bbc6 100644 --- a/src/components/switch/switch.driver.ts +++ b/src/components/switch/switch.driver.ts @@ -6,9 +6,9 @@ export const SwitchDriver = (props: ComponentProps) => { const driver = usePressableDriver(useComponentDriver(props)); const getStyle = () => driver.getElement().props.style as ViewStyle; - const getAccessibilityValue = () => driver.getElement().props.accessibilityLabel === 'on'; + const getAccessibilityValue = () => driver.getElement().props.accessibilityLabel === '1'; const isDisabled = () => driver.getElement().props.accessibilityState?.disabled === true; - const isChecked = () => driver.getElement().props.accessibilityLabel === 'on'; + const isChecked = () => driver.getElement().props.accessibilityLabel === '1'; return {...driver, getStyle, getAccessibilityValue, isDisabled, isChecked}; }; From 46c1d1af02d51f98eb957f2198d7c72118b87ef4 Mon Sep 17 00:00:00 2001 From: Inbal Tish Date: Thu, 12 Dec 2024 11:29:02 +0200 Subject: [PATCH 4/5] replace accessibilityRole with role and accessibilityLabel --- src/components/switch/index.tsx | 5 +++-- src/components/switch/switch.driver.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/switch/index.tsx b/src/components/switch/index.tsx index 8e982de92f..824b541e20 100644 --- a/src/components/switch/index.tsx +++ b/src/components/switch/index.tsx @@ -85,8 +85,9 @@ class Switch extends Component { return { accessible: true, - accessibilityRole: 'switch', - accessibilityLabel: value ? '1' : '0', + role: 'switch', + accessibilityLabel: 'switch', + accessibilityValue: {text: value ? '1' : '0'}, accessibilityState: { disabled, checked: value ? 'checked' : 'unchecked' diff --git a/src/components/switch/switch.driver.ts b/src/components/switch/switch.driver.ts index 9ff2a3bbc6..e7c60c9e51 100644 --- a/src/components/switch/switch.driver.ts +++ b/src/components/switch/switch.driver.ts @@ -6,9 +6,9 @@ export const SwitchDriver = (props: ComponentProps) => { const driver = usePressableDriver(useComponentDriver(props)); const getStyle = () => driver.getElement().props.style as ViewStyle; - const getAccessibilityValue = () => driver.getElement().props.accessibilityLabel === '1'; + const getAccessibilityValue = () => driver.getElement().props.accessibilityValue.text === '1'; const isDisabled = () => driver.getElement().props.accessibilityState?.disabled === true; - const isChecked = () => driver.getElement().props.accessibilityLabel === '1'; + const isChecked = () => driver.getElement().props.accessibilityValue.text === '1'; return {...driver, getStyle, getAccessibilityValue, isDisabled, isChecked}; }; From bff21e0dda9db19b4ada9caa4140e26e203d0ccb Mon Sep 17 00:00:00 2001 From: Inbal Tish Date: Thu, 12 Dec 2024 11:35:45 +0200 Subject: [PATCH 5/5] revert change --- src/components/switch/switch.driver.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/switch/switch.driver.ts b/src/components/switch/switch.driver.ts index e7c60c9e51..836b81a805 100644 --- a/src/components/switch/switch.driver.ts +++ b/src/components/switch/switch.driver.ts @@ -6,9 +6,9 @@ export const SwitchDriver = (props: ComponentProps) => { const driver = usePressableDriver(useComponentDriver(props)); const getStyle = () => driver.getElement().props.style as ViewStyle; - const getAccessibilityValue = () => driver.getElement().props.accessibilityValue.text === '1'; + const getAccessibilityValue = () => driver.getElement().props.accessibilityValue?.text === '1'; const isDisabled = () => driver.getElement().props.accessibilityState?.disabled === true; - const isChecked = () => driver.getElement().props.accessibilityValue.text === '1'; + const isChecked = () => driver.getElement().props.accessibilityValue?.text === '1'; return {...driver, getStyle, getAccessibilityValue, isDisabled, isChecked}; };