NoriginMedia / Norigin-Spatial-Navigation

React Hooks based Spatial Navigation (Key & Remote Control Navigation) / Web Browsers, Smart TVs and Connected TVs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remember focus on navigate back

jakubvojacek opened this issue · comments

Is your feature request related to a problem? Please describe.
First of all, thank you for this library, it helped us a lot. The last thing that we struggle now with is state persistence when navigating back. Eg, you're in 3rd row on 5th card, you select a movie, check its description, go back (via navigate(-1)). And suddenly your focus is back on 1,1 instead of 3, 5

Describe the solution you'd like
I was thinking that I would save on each page the focuskey before navigating elsewhere and then restore focus when the page is opened again. But that requires to save the focusKey manually and the restore it manually.

Describe alternatives you've considered
I am sure you must have came across this and resolved it somehow, do you please have some suggested solution how to tackle this?

Hey, thank you for reaching out.

This is a tricky one, cause it relies heavily on the navigation / route library you use and how you manage data loading.

Some of these libraries, like react-router unmount the components when you move to another screen, and others like react-navigation keep some routes mounted to allow fast transitions.

If you have a suggestion we can implement in this library that could work with different stacks feel free to share it here or open a PR.

Thanks, I wasnt aware of react-navigation (we used react-router till now). I will test it out, it sounds promising (although I am bit scared of how it will perform on those shitty TVs).

I will post a feedback once I have it.

Thanks a lot 👍