Repository navigation
Talkback announces TouchableOpacity with accessibilityRole="radio" and accessibilityState "checked" in incorrect order #45096
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
AccessibilityComponent: TouchableOpacityIssue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.Resolution: AnsweredWhen the issue is resolved with a simple answerWhen the issue is resolved with a simple answer
Description
Description
When using TouchableOpacity with accessibilityRole="radio" and accessibilityState={{checked: true}}, Talkback announces "'checked/not checked', label, 'radio button'," (Notice that the accessibility state is announced first before the label). On iOS, it is announced in correct order "label, checked/not checked)
Steps to reproduce
import React, { useCallback, useState } from 'react';
import {
StyleSheet,
Text,
TouchableOpacity,
View
} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingHorizontal: 10,
},
button: {
alignItems: 'center',
backgroundColor: 'yellow',
opacity: 0.9,
padding: 10,
margin: 10
},
countContainer: {
alignItems: 'center',
padding: 10,
},
text: {
backgroundColor: 'red',
color: 'yellow',
padding: 10,
margin: 10
},
});
export default function HomeScreen() {
const [selectedIdx, setSelectedIdx] = useState(-1);
const onStarSelected = useCallback((idx: any) => setSelectedIdx(idx), []);
return (
<View
accessibilityRole="radiogroup"
accessibilityLabel="Select rating"
>
<TouchableOpacity
accessibilityRole='radio'
style={styles.button}
onPress={() => onStarSelected(1)}
disabled={selectedIdx === 1}
accessibilityState={{
checked: selectedIdx === 1,
}}
>
<Text>1 star</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole='radio'
style={styles.button}
onPress={() => onStarSelected(2)}
disabled={selectedIdx === 2}
accessibilityState={{
checked: selectedIdx === 2,
}}
>
<Text>2 stars</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole='radio'
style={styles.button}
onPress={() => onStarSelected(3)}
disabled={selectedIdx === 3}
accessibilityState={{
checked: selectedIdx === 3,
}}
>
<Text>3 star</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole='radio'
style={styles.button}
onPress={() => onStarSelected(4)}
disabled={selectedIdx === 4}
accessibilityState={{
checked: selectedIdx === 4,
}}
>
<Text>4 stars</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole='radio'
style={styles.button}
onPress={() => onStarSelected(5)}
disabled={selectedIdx === 5}
accessibilityState={{
checked: selectedIdx === 5,
}}
>
<Text>5 stars</Text>
</TouchableOpacity>
</View>
);
}
React Native Version
0.74.2
Affected Platforms
Runtime - Android
Output of npx react-native info
expo-env-info 1.2.0 environment info:
System:
OS: macOS 12.7.5
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
Watchman: 2023.02.13.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /Users/sugi/.gem/ruby/3.1.2/bin/pod
IDEs:
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
expo: ~51.0.14 => 51.0.14
expo-router: ~3.5.16 => 3.5.16
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.74.2 => 0.74.2
react-native-web: ~0.19.10 => 0.19.12
Expo Workflow: managed
Stacktrace or Logs
N/A
Reproducer
https://snack.expo.dev/@swidjaja/touchable
Screenshots and Videos
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
AccessibilityComponent: TouchableOpacityIssue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.Resolution: AnsweredWhen the issue is resolved with a simple answerWhen the issue is resolved with a simple answer
Activity
uniqueeest commentedon Jun 21, 2024
Hi! @cortinico Can I solve this problem?
cortinico commentedon Jun 21, 2024
Please do 🙏
meetdhanani17 commentedon Jul 22, 2024
Hello @cortinico for the android we cannot change the order of sequence ("'checked/not checked', label, 'radio button',") for Talkback announcement
@swidjaja you can use accessibilityinfo api for more customization
swidjaja commentedon Jul 22, 2024
@meetdhanani17 Thank you for your response. Do you mean use the accessibilityinfo API to alter the order of announcement?
meetdhanani17 commentedon Jul 22, 2024
you can use it for provide custom message that could be use with talkback
dnhan1707 commentedon Oct 14, 2024
Hi @cortinico, I would love to tackle this problem
cortinico commentedon Oct 15, 2024
Please do 👍
dnhan1707 commentedon Oct 20, 2024
Hi @cortinico , I made some changes and now I want to test the react native version I'm having.
What are possible ways that you would recommend me to test?
I'm thinking of create a react native project and use the react native version I have but I don't know how or where to start,
cortinico commentedon Oct 21, 2024
I'd say the reccomended way here is to use RN-Tester, the reference app that you find inside
packages/rn-testerto verify your changescortinico commentedon Nov 5, 2024
After further investigation seems like this is the intended behavior:
Quoting my colleague @blavalla