react-native-windows
react-native-windows copied to clipboard
disabled TouchableHighlight still receives keyboard focus
Problem Description
from: https://github.com/microsoft/react-native-windows/issues/8781
Disabled TouchableHighlight still receives keyboard focus if onPress is defined.
Steps To Reproduce
- Set
disabled={true}
and define an onPress handler for a TouchableHighlight component - tab through and observe how it still receives keyboard focus
- vs if you remove the onPress it behaves as expected and no longer gets keyboard focus
Expected Results
No response
CLI version
6.1.0
Environment
npx react-native info
Target Platform Version
No response
Target Device(s)
No response
Visual Studio Version
No response
Build Configuration
No response
Snack, code example, screenshot, or link to a repository
<View>
<TouchableHighlight disabled={true} onPress={this._handlePress}>
<Text>text within a disabled touchable</Text>
</TouchableHighlight>
<TouchableHighlight onPress={this._handlePress}>
<Text>text within a disabled touchable</Text>
</TouchableHighlight>
</View>
The disabled TouchableHighlight still receives keyboard focus
explicitly setting focusable to false can be used as a workaround. I think we'll want to do something similar to https://github.com/microsoft/react-native-windows/pull/9840 so that when the disabled prop is set to true, we make the control not focusable/inaccessible. This will mimic the behavior in XAML