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.

Text getting focus instead of touchables (Android only)

See original GitHub issue

Description

I just upgraded to version 0.69.5-2 very meticulously and everything compiles and runs, but the focus engine seems to be focusing Text nodes now instead of Touchables. I discovered this by turning on a debug setting, then you can see the Text gets the focus instead of the button. With debug mode off it looks like the focus is not working until you click a few times (as we don’t have focus states for text).

This was not the case in the previous version we were running (0.66.3-3).

Version

0.69.5-2

Output of npx react-native info

System:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M2
    Memory: 122.89 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
    Watchman: 2022.10.31.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/wouterds/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 26, 28, 30, 31
      Build Tools: 28.0.3, 30.0.2, 30.0.3, 31.0.0
      System Images: android-31 | Google TV ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8609683
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: Not Found
    react-native-macos: Not Found
    react-native-tvos:  0.69.5-2 
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Render a screen with some touchables on top, then some text in between and then some more buttons. When navigating down from the top you will first pass through the text nodes and only then land on the touchables on the bottom.

Snack, code example, screenshot, or link to a repository

I currently don’t have a demo project to show this behaviour but can look into one if desired and we don’t get this sorted out else.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
wouterdscommented, Nov 15, 2022

I ended up creating a custom Text component where we set the default value for accessible to false.

import React, { memo } from 'react';
import { Text as RNText, TextProps as RNTextProps } from 'react-native';

type Props = RNTextProps;

export type TextProps = Props;

const Text = (props: Props) => (
  <RNText
    {...props}
    accessible={props.accessible || false}
  />
);

export default memo(Text);

Re-opened the issue as it seems it is not specific to my setup/project.

1reaction
wouterdscommented, Nov 22, 2022

@douglowder Did as instructed, and was able to compile the archive with the patch (https://github.com/wouterds/react-native-tvos/commit/cdf7f9c55fb35440eaba5a861b4b2778007ba6fa) & placed it in node_modules/react-native/android but the issue remains.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Disable EditText editability and focus (like TextView)
I'm not sure what focusableInTouchMode does, but it doesn't remove the focus when I keep touching.
Read more >
Is there a way to keep the keyboard open even when input ...
Focus works differently in iOS than on the Web - buttons in iOS can't accept focus, only keyboard input fields, so normally this...
Read more >
LinearLayout | Android Developers
This view will get focus only if none of its descendants want it. ... Add any touchable views that are descendants of this...
Read more >
Handling Touches - React Native
The "Touchable" components provide the capability to capture tapping gestures, and can display feedback when a gesture is recognized. These ...
Read more >
Seven Tips To Help with Android Accessibility Development
If we decide to not only focus the OS accessibility delegate or any ... know it's a touchable component) it'll also filter out...
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