Skip to content

Focus jumps after screen navigation when using SpatialNavigationRoot — breaks without it due to VirtualizedList dependency #195

@dheenavk

Description

@dheenavk

Hi team

I'm using react-tv-space-navigation in my React TV project, and I’ve run into a focus issue when navigating between screens.

Problem Description

I wrap each screen/page with its own . When I navigate from one screen to another, the initial focus looks correct. However, as soon as I press a direction key (like Down or Right), the focus jumps to an incorrect item.

For example:

On Screen A, I navigate to Screen B.

On Screen B, the first focus is on item-1 as expected.

But when I press the Down button, it jumps directly to item-3, skipping item-2.

It feels like the navigation tree isn't fully resetting, or maybe previous focus history is interfering

Expected Behavior::

When navigating to a new screen:

The focus should be reset cleanly.

Directional focus should move linearly (e.g., item 1 → item 2 → item 3).

Steps to Reproduce
Use on each screen.

Navigate from one screen to another.

Set initial focus using autoFocus or defaultFocus.

Press the Down/Right key.

Focus skips the next logical item.

and i am using same example code like

<SpatialNavigationVirtualizedList
// Do not forget to memoize data
data={data}
renderItem={renderItem}
// Do not forget to memoize this if you provide it as a function
itemSize={50}
numberOfRenderedItems={10}
numberOfItemsVisibleOnScreen={5}
onEndReached={() => {
// Handle reaching the end of the list
// you might trigger your backend pagination for example
}}
style={styles.container}
orientation="horizontal"
/>

// ScreenA.tsx

<Focusable onEnterPress={() => navigate("ScreenB")} />

// ScreenB.tsx




Workaround:

As a test, I commented out from the screen component.

Result:
The jumping issue goes away, and focus behaves as expected across screens.

BUT it throws an error: SpatialNavigationVirtualizedList must be used inside a SpatialNavigationRoot like this

So I'm stuck between:

Jumping focus when the root is present

Runtime error when the root is removed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions