-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 history support, enable advanced focus restoration
#37223
Conversation
Size Change: +1.25 kB (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
f6b6335
to
869bcde
Compare
6c65d06
to
4493d59
Compare
Navigator
: basic history support, enable focus restorationNavigator
: add basic history support, enable focus restoration
Navigator
: add basic history support, enable focus restorationNavigator
: add basic history support, enable advanced focus restoration
packages/components/src/navigator/navigator-screen/component.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/navigator/navigator-screen/component.tsx
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/global-styles/navigation-button.js
Outdated
Show resolved
Hide resolved
Not sure if you're aware of this, but we've recently done other approach to try to implement a custom client side router in the side editor. See #36488 for the basic implementation and #37314 for focus management and some refactor. The approach we take there is to make it browser-first, and use the Even though we currently don't have the need to implement a real browser-based client side router, I think it's still good to take it into account in case we ever have the requirement to do so. Maybe we could combine the two into this component and learn from each other? |
@kevin940726 yeah browser navigation has actually been part of the initial implementation of the Navigator component but we felt that it's not something that is needed in all use-cases and not something that should be backed into a UI component, for this reason we decided to built a generic UI component and still have an API that allow syncing with browser history if needed for non-mobile/web apps like edit-site. The original prototype here #32923 has a mechanism to sync navigation state with history that could serve as inspiration. |
Hey @kevin940726 and @youknowriad , I created #37355 to discuss the interaction between |
…`isFirstRender` in the `NavigatorScreen`
…hing a new location
11a72bb
to
ba08a42
Compare
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.
This is looking good to me overall. Great work
packages/components/src/navigator/navigator-back-link/component.tsx
Outdated
Show resolved
Hide resolved
I don't have any more feedback in this PR, I'm really satisfied with how this is shaping up. Would be good to get a bit more testing and 🚢 |
This is great to hear! I was initially thinking of splitting the changes in this PR into 3 separate PRs for ease of review/track-ability — they could be:
Would you be ok with that? Otherwise I can just continue the work in this PR (adding unit tests, refining docs...) before asking other folks for a final review. |
@ciampo whatever works best for you. The current size of the PR is still manageable/easily reviewable but if you want to ship some things more quickly, go split it :) |
In that case, I'm going to close this PR. I will open a few smaller PRs instead — thank you again for your feedback so far! |
Description
Following the conversation in #37063, this PR is an exploration into enabling focus restoration when navigating back
Changes:
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)NavigatorScreen
would focus its first tabbable element when mountedquerySelector
, and it is the responsibility of the developer to make sure that each link can be correctlyselected
by providing a working selector.TODO:
NavigatorLink
Navigator
's unit testsNavigator
README and JSDocs (including the@example
s)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).