mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
f3847eeec2
Summary: >Finally, the last catch relates to why these views are considered focusable. We've been working with the assumption that they are only focusable because accessible="true", but this is not the only property that can make a view focusable on Android. Android also makes all elements with onClick listeners or onLongPress listeners focusable Adding onPress handler to a Text Component does not call setClickable(true) ([test case](https://github.com/facebook/react-native/issues/30851#issuecomment-1194957300)) https://github.com/facebook/react-native/issues/30851#issuecomment-1196297746 Pressable, TouchableOpacity, Switch, TextInput, and TouchableNativeFeedback are focusable/accessible by default without an onPress handler or accessible prop. ```jsx <TouchableOpacity /> ``` The TouchableOpacity is accessible ```jsx <TouchableOpacity accessible={false} /> ``` The TouchableOpacity is not accessible ```jsx <TouchableOpacity accessible={false} onPress={() => console.log('pressed')} /> ``` The TouchableOpacity is accessible. https://github.com/facebook/react-native/blob/a70354df12ef71aec08583cca4f1fed5fb77d874/Libraries/Components/Touchable/TouchableOpacity.js#L249-L251 This and other PRs fixes https://github.com/facebook/react-native/issues/30851 ## Changelog [Android] [Fixed] - Text with onPress or onLongPress handler is not accessible with TalkBack Pull Request resolved: https://github.com/facebook/react-native/pull/34284 Test Plan: main branch https://github.com/facebook/react-native/issues/30 <details><summary>pr branch</summary> <p> <video src="https://user-images.githubusercontent.com/24992535/181207388-bbf8379b-71b8-44e9-b4b2-b5c44e9ac14d.mp4" width="1000" /> </p> </details> Reviewed By: cipolleschi Differential Revision: D39179107 Pulled By: blavalla fbshipit-source-id: 3301fb2b799f233660e3e08f6a87dad294ddbcd8