SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Fix Custom Focus Ordering for FocusForward, FocusBackward and nested children (#51575)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51575

Before we were relying on absolute focus direction to determine the next focusable view inspired by Recycler View's implementation. This turned out to be inaccurate since FocusForward and FocusBackward do the ordering differently.

For FocusForward and FocusBackwards the children of the root node are ordered first from top to bottom then, row groups are created by getting views with the same vertical position and then everything else is sorted left to right.

Android creates an array with this order and then just focuses the next or previous element of this list. We don't do this but now FocusForward and FocusBackward follow the some comparisons used to build this array on Android.

Also, there was an issue with nested children within an accessible view, this just needed a bit of refactor on the focusSearch function so that we can tell when we actually need to trigger our custom focus search

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D75301251

fbshipit-source-id: 93b708092299afa778ba5938b093c2c38209b497
J
Jorge Cabiedes Acosta committed
2c04b54c051b8f69275cf093096b7eaa1a3b738e
Parent: 091eb2e
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 5/28/2025, 9:34:22 PM