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

SpatialNavigationVirtualizedList default position #144

Open
Veryyapeee opened this issue Jul 14, 2024 · 7 comments
Open

SpatialNavigationVirtualizedList default position #144

Veryyapeee opened this issue Jul 14, 2024 · 7 comments

Comments

@Veryyapeee
Copy link

Is your feature request related to a problem? Please describe.
Currently there is no way to set default/initial focus index on virtualized list
There is no even any ScrollTo method exposed

Describe the solution you'd like
Add prop for initial index, or expose anything like ScrollTo method

Describe alternatives you've considered
Wrapping stuff in

@pierpo
Copy link
Member

pierpo commented Jul 15, 2024

Hey!
There is a method, it's just called focus but not scrollTo 😁
https://github.com/bamlab/react-tv-space-navigation/blob/main/docs/api.md#spatialnavigationvirtualizedlist

Using a little useEffect you should be able to add your default focus 😁

I'm closing, feel free to tell me if it's not enough!

@pierpo pierpo closed this as completed Jul 15, 2024
@Veryyapeee
Copy link
Author

Hey! There is a method, it's just called focus but not scrollTo 😁 https://github.com/bamlab/react-tv-space-navigation/blob/main/docs/api.md#spatialnavigationvirtualizedlist

Using a little useEffect you should be able to add your default focus 😁

I'm closing, feel free to tell me if it's not enough!

It's kinda okay, but the issue is that calling focus works with animation, and if I have like 2 lists, and I want to set default index to for example 3, entering screen is ugly, lists are moving, adding possibility to disable animation while imperatively focusing target element, would be awesome

@pierpo
Copy link
Member

pierpo commented Aug 26, 2024

Makes sense! Let's reopen 😉
Thanks!

@pierpo pierpo reopened this Aug 26, 2024
@pierpo
Copy link
Member

pierpo commented Aug 28, 2024

I was discussing this feature with the others. We were wondering: why would you need a default position that is not the position 0?
What is the use case?

We think that it's a little weird, because this might hide content from the user if the list is not at the beginning, right?

@Veryyapeee
Copy link
Author

I was discussing this feature with the others. We were wondering: why would you need a default position that is not the position 0? What is the use case?

We think that it's a little weird, because this might hide content from the user if the list is not at the beginning, right?

Actually this is a very common practice among any kind of OTT applications, like:

Banner -> showing "netflix" like banner with pagination dots, a lot of companies likes to set default item to idx=1
EPG list (program schedule for tv content) - most of the times we want to show first item as the item which is currently playing, but allow user to go back in the list to browse "catch up" content

There are a lot of use cases

@pierpo
Copy link
Member

pierpo commented Aug 28, 2024

OK, thank you for the very quick answer 🙌
I confirm that we add it to our backlog 👍

@Veryyapeee
Copy link
Author

OK, thank you for the very quick answer 🙌 I confirm that we add it to our backlog 👍

Also I've noticed a problem when I've tried to implement workaround using .focus method on list ref

When I have multiple lists that come from external API, and I call .focus on each of them (each of them have different initial position), there is a problem, in which I press any button, and focus is redirected automatically to last list, which is also not ideal

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

2 participants