question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Focus system ignores disabled prop in touchables

See original GitHub issue

Setting 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

  1. Create an app with several touchables, some of them disabled
  2. 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:closed
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
douglowdercommented, Aug 28, 2020

This is merged to the tvos-v0.63.1 release branch, and will be in the next 0.63 npm release.

1reaction
douglowdercommented, Aug 20, 2020

It will also work on Android if you set disabled to true, accessible to false… are you ok with that?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found