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.

Different focus order tvOS/Android

See original GitHub issue

Description

In tvOS: We have a custom GoBack component on a screen which is getting focus before the screen’s useFocusEffect is run, causing the screen to lose focus immediately it is shown, effectively rendering it inaccessible.

In Android: The same GoBackdoes not get focus until the user actively backs out of the screen.

But why the different focus behaviour? Does it indicate a bug or that we are doing something wrong here?

NB: We’re still currently unable to proceed beyond 0.63.4-0 at the moment so bear with us on that, if possible 😕

React Native version:

Run react-native info in your terminal and copy the results here.

info Fetching system and libraries information… System: OS: macOS 11.5.2 CPU: (8) x64 Intel® Core™ i7-8569U CPU @ 2.80GHz Memory: 127.72 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.10.0 - ~/.nvm/versions/node/v15.10.0/bin/node Yarn: 1.22.11 - ~/.nvm/versions/node/v15.10.0/bin/yarn npm: 7.6.3 - ~/.nvm/versions/node/v15.10.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0 Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3 System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Android TV Intel x86 Atom, android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 13.1/13A1030d - /usr/bin/xcodebuild Languages: Java: 1.8.0_282 - /usr/bin/javac Python: 3.7.3 - /Users/aa/.pyenv/shims/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: Not Found react-native-macos: Not Found react-native-tvos: 0.63.4-0 npmGlobalPackages: react-native: Not Found

Steps To Reproduce

  1. Run the app in tvOS, navigate to the event details screen. Notice that you are pulled instantly back to the “swim lanes” view.
  2. Run the app in android, navigate to the event details screen. Notice that you can view the screen then back out to the “swim lanes” view at your leisure.

Expected Results

I expect that both platforms should handle the focus events in the same order.

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

This Royal Opera House project, as you may recall, is fully out in the open 😃

I have added a workaround in this branch. I hide the GoBackcomponent until we are sure the useFocusEffect has run, essentially.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
douglowdercommented, Nov 9, 2021

Yes please create a new issue for this. The right way to fix this is with TVFocusGuideView, but it seems tricky to get that to work correctly in this app for some reason.

0reactions
sinewave440hzcommented, Nov 8, 2021

Still not sure actually whether I should create a new issue for this. To clarify a bit, the android navigation away from the menu works correctly - I expect that nextFocusRight is used correctly there by react-navigation. In tvOS however, we are relying on hasTVPreferredFocus being updated correctly per DigitalEventItem, which isn’t happening when the menu item changes. Looking at how to get that to happen…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to move the focus from a button to another in tvOS?
Start by overriding the preferredFocusedView in your viewController with a custom property: var myPreferredFocusedView:UIView? override var ...
Read more >
Taking Control of the tvOS Focus Engine - Code - Envato Tuts+
In this tutorial, we take an in-depth look at the tvOS focus engine. You learn how it works and how to control it...
Read more >
Working with tvOS Navigation and Focus in Xamarin
This article covers the concept of Focus and how it is used to present and handle Navigation inside of a Xamarin.tvOS app.
Read more >
Focus Navigation in AndroidTV with React Native
In this article, we will implement focus navigation with remote control on AndroidTV using React Native. Follow along as we develop the app!...
Read more >
Overcoming tvOS Development Challenges: Focus ... - Medium
For users, the focus indicates where the users are within the app and helps them navigate between elements. In order to ease navigation...
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