Norigin-Spatial-Navigation icon indicating copy to clipboard operation
Norigin-Spatial-Navigation copied to clipboard

Remember focus on navigate back

Open jakubvojacek opened this issue 1 year ago • 2 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?

jakubvojacek avatar May 12 '24 15:05 jakubvojacek

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.

xavi160 avatar May 17 '24 10:05 xavi160

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 :+1:

jakubvojacek avatar May 17 '24 12:05 jakubvojacek

react-navigation is for react native Should it be work with react?

mehardiknaik avatar Sep 01 '24 03:09 mehardiknaik

react-navigation is for react native. Should it be work with react?

React navigation has web support by using React Native Web. Therefore, it will work with any react project. Nevertheless, installing react-native-web will increase your bundle size significantly compared to only installing react.

guilleccc avatar Sep 02 '24 09:09 guilleccc

The consensus is that it's not this library responsibility to handle this and as such I am closing this.

Thanks everyone.

predikament avatar Sep 13 '24 18:09 predikament