Skip to content

Conversation

@Abbondanzo
Copy link
Contributor

Summary:
The hasTVPreferredFocus prop is functionally similar to the focusable prop. On iOS, the props are identical. The primary difference appears on Android, where the prop attempts to request focus when set to true. Attempting to invoke imperative API calls through declarative means has been a source of confusion and we should instead recommend requesting focus through imperative means, like calling focus() on a specific view's ref instead. Workarounds presented rely on lifecycle methods to request focus natively.

This change only marks these methods as deprecated on JS. In the following version, they will be removed from the public API.

Changelog: [General][Deprecated] - Deprecate hasTVPreferredFocus

Differential Revision: D76732539

Summary:
The `hasTVPreferredFocus` prop is functionally similar to the `focusable` prop. On iOS, the props are identical. The primary difference appears on Android, where the prop attempts to request focus when set to true. Attempting to invoke imperative API calls through declarative means has been [a source of confusion](react-native-tvos/react-native-tvos#237) and we should instead recommend requesting focus through imperative means, like calling `focus()` on a specific view's ref instead. Workarounds presented rely on lifecycle methods to request focus natively.

This change only marks these methods as deprecated on JS. In the following version, they will be removed from the public API.

Changelog: [General][Deprecated] - Deprecate `hasTVPreferredFocus`

Differential Revision: D76732539
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jun 16, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76732539

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in cfb6c96.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @Abbondanzo in cfb6c96

When will my fix make it into a release? | How to file a pick request?

@Abbondanzo Abbondanzo deleted the export-D76732539 branch June 17, 2025 01:17
douglowder pushed a commit to react-native-tvos/react-native-tvos that referenced this pull request Jun 30, 2025
This commit is empty for React Native TV.

Summary:
Pull Request resolved: facebook/react-native#52043

The `hasTVPreferredFocus` prop is functionally similar to the `focusable` prop. On iOS, the props are identical. The primary difference appears on Android, where the prop attempts to request focus when set to true. Attempting to invoke imperative API calls through declarative means has been [a source of confusion](#237) and we should instead recommend requesting focus through imperative means, like calling `focus()` on a specific view's ref instead. Workarounds presented rely on lifecycle methods to request focus natively.

This change only marks these methods as deprecated on JS. In the following version, they will be removed from the public API.

Changelog: [General][Deprecated] - Deprecate `hasTVPreferredFocus`

Reviewed By: andrewdacenko

Differential Revision: D76732539

fbshipit-source-id: 64912b4dacb76cd40e79148c1082d8ed8f573879
@douglowder
Copy link
Contributor

@Abbondanzo @cipolleschi just a heads up from the React Native TV repo -- this change caused a slight regression in the TV repo when it was merged from upstream, as this API is used there. For the record, hasTVPreferredFocus is a completely different API from focusable -- it marks a view as initially focused by the TV focus engine when the screen is first rendered.

If possible, it would be great to add me to the review for any future PRs like this that affect TV APIs 😄

Thanks very much, and I apologize for not catching this sooner!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants