-
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
Components: Assess stabilization of Navigator
#60927
Components: Assess stabilization of Navigator
#60927
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @lysyjan. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
To be honest, I'm hesitant here. We moved away from this component recently in the site editor. It's still used in a few places but could largely be simplified as it's main purpose seem to be Animation and Focus Management. I can be convinced otherwise though :) What do you think @jsnajdr |
First of all the WooCommerce uses it to implement a navigation sidebar in Customize Store. It's the same code as Site Editor before #60466, including the Then there's MailPoet, which uses Then I found the Otter Blocks plugin, which uses This again is a legitimate use, Core uses it the same way. Another plugin is Visual Portfolio. I didn't install this one, but from the code it looks like an another example of a legitimate plugin settings sidebar. Therefore, it seems like a good idea to finally stabilize |
@jsnajdr The current implementation of the styles sidebar in the new email editor is behind a feature flag. We are working on adding the next NavigatorScreens, and we follow implementation in the Global Styles sidebar, as the design is very similar. |
Navigator
Navigator
We're using this Navigator for pattern category navigation. In there, I used the |
Just pinging @youknowriad to make sure he's ok with removing the Also,
@jsnajdr I'm not sure this is feasible, given that
@jeryj I don't think this is something that
|
I don't mind the removal of goToParent but from my perspective goBack is more problematic (unexpected behavior in most cases) than goToParent. |
I'm personally also OK keeping |
I've been looking at |
To control the
|
I agree but it's better than history which is very random, specially if there's programatic navigation in the middle. When you see the back button in the Navigation UI, you expect it to go up the tree of navigation, not back in history. In that sense I prefer goToParent behavior over goBack for a UI component. As opposed to "TabPanels", "Navigator" is a tree of screens, so going up and down makes sense. I don't see any valid use-case for Navigator where it's not really a tree. |
It's definitely important that we agree on the APIs that What should the role of A brief recapFrom what I recall, when it was created, the main idea behind
For its first implementation, we opted for storing an array of location history. Navigating to a new location would push a new location item to the stack, and going back would pop an item from the stack. This was a simple implementation, but it allowed "back" links to be agnostic of the previous history locations, and it allowed to store a reference to which element focus should be moved to when navigating back. Later on, as the site editor started to become more complex, we needed a way to go "back" to what, in the hierarchy of screens was the "previous" screen, even if the user didn't actually visit that screen. The "location stack" technique couldn't help here, and that's why we introduced the concept of "goToParent". Moving forwardOne potential approach could be to greatly simplify In practical terms:
What do you think? |
I'm not sure about this, because as @youknowriad says, navigator is a tree:
And the back button is practically always there so it makes sense to somehow support it natively: The problem is that a generic "go back" solution that works for everyone is possible only for simple trees where each node has one parent: Here it doesn't even matter whether we use But in Site Editor we eventually ended up doing cross-tree navigations where there were multiple ways to get to, e.g., a pattern page: Also, the pattern matching and named arguments from #47827 make the tree more complicated. So there is a tradeoff: as the tree gets more complicated, the generic This leads me to a question: how complex trees do we want to support in |
Yes, this my take as well. The component has always been about rendering a simple "tree" of screens where there's only one way to go up and down. I think we still want to support a way to go to a particular place in tree programmatically, but clicking the back button should always navigate up the tree for me. |
One way to simplify
The only thing is that "back" navigation will break for consumers of Also, without storying location history, we'd likely lose the ability to restore focus to the element that generated the view transition (we can still focus the first focusable element on the view) |
Well that's a reason to keep the location history 🙂 The point is that
For public plugins, we can review all usages (in plugins like Otter Blocks or Visual Portfolio), there are not so many. And I think all of them are going to use hierarchical paths. I don't remember seeing anything unusual when I was reviewing them 2 months ago. |
I was just a bit confused by the few mentions about "largely simplifying" the component. If we keep the location history AND the "go back to parent" functionality, then most of the implementation won't be touched.
I personally think that keeping |
I was reflecting on how currently I also don't think that browsers restore focus this way when navigating back, nor the most used third-party routers. With this in mind, I'm thinking that it could be worth dropping the location history logic completely and fallback to a simpler focus restoration strategy, which would allow us to simplify |
Having it restore focus to the previously activated navigation item is very nice for keyboard navigation. It makes things much simpler and faster to use. Losing this behavior would be a big step backwards, IMO. |
Got it. Judging by the conversations above, it looks like the only simplification to Location history stack should be kept around for focus restoration purposes. I will start working on this soon and post updates. |
I agree that the focus restoration is a very nice feature. Few apps do this today and the code is ugly, but there is a big benefit for the keyboard user. macOS Finder restores the last selected item when going up in the filesystem hierarchy (⌘↑ and ⌘↓): finder-keyboard-nav.movInteresting that the web version of Dropbox also has a very similar file navigator UI, but keyboard navigation is broken: when going up, you lose the selection. |
Closing in favour of #64613 |
Issue: #59418.
What?
This is part of a larger effort to remove
__experimental
prefix from all "experimental" components, effectively promoting them to regular stable components. See the related issue for more context.Why?
The strategy of prefixing exports with
__experimental
has become deprecated after the introduction of private APIs.How?
__experimental
prefix;__experimental
export for backwards compatibility;__experimental
in GB and components to the one without the prefix (including in storybook stories). Also, update the docs to refer to the new unprefixed component;id
(get it from the storybook URL) to thePREVIOUSLY_EXPERIMENTAL_COMPONENTS
const array inmanager-head.html
so that old experimental story paths are redirected to the new one;