-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property hasTVPreferredFocus has a 1 second delay on tvOS #23527
Comments
This comment has been minimized.
This comment has been minimized.
Just removed the delay and everything seems to work fine and the app behaves now like it should. Any idea what I am missing?
|
@hufkens the code with the delay was like 2 years old, my guess is it was done in order to ensure the focus switched on re-renders. I will open a PR for removing the delay after I test a few more scenarios, such as switching focus during renders. |
@ericlewis Thanks for the response. We are struggling a lot with focus and react-native. But looks like we are slowly getting there. I patched the code in our project so I'll let you know if we have any strange side-effects. |
Please update here when it will be released. We are waiting this fix too :) |
It'd be interesting to understand why this was done in the first place - I assume this was not just for the fun of it :) For now we've patched it as well, but it's clearly not an ideal solution |
Probably because react-native doesn't use AutoLayout, but the FocusEngine works with the AutoLayout there could be a delay. Problem is that having a 1 second delay is really weird and unusable if you want to use it. Also we miss the FocusGuide in react-native. The FocusGuide is a component that can be used to direct the focus from one component to another if there is no direct line of sight (up, down, left, right). We found a way to directly set focus to a RCTView:
|
Nice one ! Have you tried using a ref and call I see we're facing the same problems :) I agree the 1 second delay isn't usable, but if it's here for a reason, maybe we should not just trash it like that. |
@f-roland That would be awesome. If you need any help let me know. |
Discovered on: facebook#23527 This might be dumb to undo this, but everything seems to be working fine for right now.
We have been avoiding hasTVPreferredFocus because of this issue. Is patching RN working? |
This is fixed in the new community repo for tvOS (react-native-tvos/react-native-tvos#2), and is part of the first NPM release ( |
BughasTVPreferredFocus.zip
🐛 Bug Report
We are using React Native to build an app for all platforms including Apple TV.
We need the
hasTVPreferredFocus
property to show initial focus. But there seems to be a hard-coded delay of 1 sec in the code.To Reproduce
Create a project for tvOS.
Add a
<View>
component with a couple of<TouchableHighlight>
components. Set thehasTVPreferredFocus
property of the last one to true.The component will render but the last component will get the focus after a one second delay.
Expected Behavior
The last one should be focused in render, without the 1 second delay.
Code Example
Native code with the delay.
Environment
The text was updated successfully, but these errors were encountered: