Repository navigation
feat(focus): focus keys, destination keys and exits - #128
Merged
Merged
Conversation
RuudBurger
marked this pull request as ready for review
October 5, 2026 12:19
DouweBos
approved these changes
Oct 8, 2026
RuudBurger
force-pushed
the
ruud/focus-regions
branch
from
October 8, 2026 15:08
71695cb to
7cd466d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for running the native focus regions from the Plex app on Lightning (app side: https://github.com/plexinc/react-native-client/pull/6698). The engine had no way to name an element, so anything key based (destinations, exits, focusByKey) had to be worked around from outside.
What changed
focusKeyon FocusGroup / useFocus registers an element under a string,FocusManager.focusByKey(key)focuses it (false if nothing is mounted under it)destinationKeys: ordered keys that arriving focus is forwarded to, first mounted one wins.firstandlast-focusedstand for the group's own first and remembered childexits: a key per direction for when a move finds nothing inside the group (only used then, same as before for traps)nativeIDas its keyfirst,last-focused, spatial),rememberAsper value, scopes, nearest repick when the remembered node is gone, and enter/leave eventsrememberAsswaps the whole remembered chain (a value that comes back returns to its item by focus key, so recycled list cells stay right), andrefocusInitialholds the repick while its target is still mounting (at most 1 s)useFocusregisters once and updates with a single effectSetters for the new options run before the node is in the tree (the parent registers a render later), so they also go through
addElementoptions, same asdestinations.Tested with unit tests (FocusKeys.spec.ts, FocusRegions.spec.ts, 356 passing in the package) and against the 42 Plex focus cases in the Lightning storybook: all 42 pass.