Focus system ignores disabled prop in touchables
See original GitHub issueSetting the disabled prop on touchables has no effect on the ability to focus the touchable. onPress is not triggered when the select button is pressed, as expected.
I wanted to try with RN’s Pressable component but it doesn’t look like we have merged 0.63 yet.
I am testing on android by the way, not sure if it happens on tvos. Decided to report here because it doesn’t look like RN core wants to support TV devices anymore.
React Native version:
System:
OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-4700HQ CPU @ 2.40GHz
Memory: 242.80 MB / 15.52 GB
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 10.22.0 - /usr/bin/node
Yarn: 1.21.1 - /usr/bin/yarn
npm: 6.14.6 - /usr/bin/npm
Watchman: 4.9.0 - /home/linuxbrew/.linuxbrew/bin/watchman
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: 11.0.8 - /usr/bin/javac
Python: 2.7.17 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: ^16.13.1 => 16.13.1
react-native: Not Found
react-native-tvos: 0.62.2-1
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
- Create an app with several touchables, some of them disabled
- Cycle through the touchables with directional pad actions (up down left right)
Describe what you expected to happen: Expected the focus system to skip disabled touchables
Snack, code example, screenshot, or link to a repository:
import React from 'react'
import { View, TouchableOpacity, Text } from 'react-native'
const App = () => {
return (
<View>
<TouchableOpacity hasTVPreferredFocus style={{ backgroundColor: '#000'}}>
<Text style={{ color: '#fff'}}>Button 1</Text>
</TouchableOpacity>
<TouchableOpacity disabled style={{ backgroundColor: '#000'}}>
<Text style={{ color: '#fff'}}>Button 2</Text>
</TouchableOpacity>
</View>
)
}
export default App
Issue Analytics
- State:
- Created 3 years ago
- Comments:14
Top Results From Across the Web
Problem setting disabled prop and focus from the same function
Setting focus on a DOM element is a side-effect, it should be done within useEffect: import React, { useState, useRef, useEffect } from ......
Read more >TouchableWithoutFeedback - React Native
function MyComponent(props) { ... Props. accessibilityIgnoresInvertColors ... By default, all the touchable elements are accessible.
Read more >Disabled Touchable inside (enabled) Touchable prevents ...
The problem A disabled touchable prevent the onPress event to bubble to the next touchable ancestor. How to reproduce Place a disabled ......
Read more >Accessibility · React Native
When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible....
Read more >How can I make a disabled button focusable, clickable, in ...
Answer. Swap your disabled attribute for aria-disabled="true" . This will allow the element to maintain most of its properties that allow you to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This is merged to the
tvos-v0.63.1release branch, and will be in the next 0.63 npm release.It will also work on Android if you set
disabledto true,accessibleto false… are you ok with that?