-
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: simplify backwards navigation APIs #63317
Conversation
f9155ed
to
1a6ecf2
Compare
…r NavigatorGoBackButton
05b5131
to
7650c06
Compare
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 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. |
raw: '/ "\'><=invalid_path', | ||
escaped: "/ "'><=invalid_path", |
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.
Because of "going back" always behaving like "go to parent", all paths need to start with /
in order to work well with the component's pattern matching logic
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 looks good to me 👍
Left a few minor suggestions.
I appreciate the simplification here. Makes the API clearer and more predictable, and the consumers better aware that they should prepare their navigation structure in a more hierarchical one-to-one way.
@@ -4,6 +4,8 @@ | |||
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes. |
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.
Sounds like we can remove the experimental callout now.
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 was planning on removing those experimental callouts and Storybook tags once we also export the component without the experimental prefix (in a follow-up PR)
deprecated( '`goToParent` prop in wp.components.NavigatorBackButton', { | ||
since: '6.7', | ||
alternative: | ||
'"back" navigations are always treated as going to the parent screen', |
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.
Should we just suggest goBack()
? For someone attempting to use goToParent
, it's not immediately clear in their IDE that goBack
is the recommended alternative.
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.
The NavigatorBackButton
doesn't have a goBack
prop, since "going back" was already the default behavior. The goToParent
prop was changing that behaviour, but now that the default behaviour of "going back" is the same as "going to parent", that prop basically became a no-op and can just be omitted.
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.
Ah, got it, makes sense.
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.
Actually thanks to your comment, I realised that this deprecation was not necessary because that was a code path that could not be hit anymore. I just removed the code instead: da79e35
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.
Perfect 🧹
This can be done because its usage was actually only internal to the component
14dbcb8
to
c24eec9
Compare
What?
As discussed in #60927 , this PR introduces a few simplifications (and deprecations) to the
Navigator
component.Why?
We're simplifying the component's API ahead of promoting to stable.
How?
NavigatorToParentButton
,NavigatorBackButton.goToParent
anduseNavigator().goToParent()
as deprecateduseNavigator().goBack()
andNavigatorBackButton
will navigate to the parent screen, instead of navigating to whatever screen was visited prior to the current one (according to the expected URL-basedpath
assigned to screens)Questions
goToParent
andNavigatorToParentButton
?replace
option make any sense with "go to parent"-only backwards navigation?Next steps
Testing Instructions
Navigator
should continue to behave as ontrunk
in Storybook and in the block editor