-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Navigator
: add basic location history
#37416
Conversation
Size Change: +75 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
28b64a7
to
86db45f
Compare
// previous and the new location. | ||
// Also force the `isInitial` flag to `false` for the new location, to make | ||
// sure it doesn't get overridden by mistake. | ||
setLocationHistory( [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a limit to this array (like 10 items or so)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the motivation for it?
Adding a limit would have a few consequences. Let's say the limit is 10 — it means that, when we navigate to the 11th location, we would either:
- prevent any further navigation (since the stack is full). This approach doesn't seem very viable in terms of UX, since it would suddenly prevent the user from navigating to another screen. OR
- drop the initial root location, and make the second location in the array the new "root". This would introduce further complexity in the code (shifting the array, re-setting the
isInitial
prop, ...) and it would also mean that the user wouldn't be able to navigate back all the way to the initial route.
I personally think that, rather than enforcing a hard limit on the array, we should tackle this potential issue by making sure that our UIs are not designed to require too many levels of "screen nesting" in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @youknowriad , do you have any additional thoughts on my previous answer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't reply here. I was just thinking about memory leaks but as you said, it might not grow much so fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine, thank you!
310ea40
to
b8abecd
Compare
Description
Following the conversation in #37063 and the exploratory work done in #37223, this PR is the first step towards adding support for advanced focus restoration in
Navigator
. The plan is to have the work split across 3 PRs:NavigationLink
andNavigationBackLink
components (future PR)This PR adds a basic implementation of location history to the
Navigator
component.Navigator
component, especially the shape of the context object: it now exposeslocation
(the current location),push
(used to navigate to a new location), andpop
(used to navigate to the previous location)How has this been tested?
Screenshots
Storybook
navigator-focus-restoration.mp4
Preferences Modal
preference-modal-focus-restoration.mp4
Global Styles Sidebar
global-styles-sidebar-focus-restoration.mp4
Types of changes
New feature (technically not breaking, since the component is experimental)
Checklist:
*.native.js
files for terms that need renaming or removal).