Skip to content
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

Add imperative focus in SpatialNavigationVirtualizedGrid #166

Open
arthuruan opened this issue Nov 6, 2024 · 0 comments
Open

Add imperative focus in SpatialNavigationVirtualizedGrid #166

arthuruan opened this issue Nov 6, 2024 · 0 comments

Comments

@arthuruan
Copy link

arthuruan commented Nov 6, 2024

Is your feature request related to a problem? Please describe.
I'm trying to go back the focus to the header of SpatialNavigationVirtualizedGrid, but looks like from the third row I lose the reference of the component and I'm not able to do the imperative focus.

Describe the solution you'd like
I'd like to have I way to keep the header reference while scrolling down. Or even expose the SpatialNavigationVirtualizedList reference in the SpatialNavigationVirtualizedGrid component, would be very helpful. With that, I could scroll to the first grid item and then move the focus to the header. Like that:

 <SpatialNavigationVirtualizedGrid
      ref={virtualizedListRef}
      data={data}
      header={header}
      headerSize={headerSize}
      renderItem={renderItem}
      itemHeight={getItemHeight(itemAspectRatio)}
      numberOfColumns={NUMBER_OF_COLUMNS}
      onEndReachedThresholdRowsNumber={INFINITE_SCROLL_ROW_THRESHOLD}
      onEndReached={onEndReached}
      descendingArrowContainerStyle={styles.topArrowContainer}
      ascendingArrowContainerStyle={styles.bottomArrowContainer}
    />
 useRemoteControlKeys(
    [SupportedKeys.Back],
    useCallback(() => {
      if (isItemFocused) {
        virtualizedListRef.current?.focus(0);
        headerViewRef.current?.focus();
        return true;
      }

      return false;
    }, [isItemFocused]),
  );

Additional context

Screen.Recording.2024-11-06.at.11.28.34.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant