-
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
Sidebar: Restore Back buton 'go to parent' functionality #52910
Conversation
Size Change: +13 B (0%) Total Size: 1.44 MB
ℹ️ View Unchanged
|
Flaky tests detected in 2a57746. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5651011582
|
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.
Code LGTM and works as expected in testing:
- Clicking "back" from 404 or Search page still takes us to Pages;
- Trashing a page and clicking back from pages takes us to Design;
- Navigating from the Templates section to a page with command palette and clicking back takes us to Pages.
E2e failures seem unrelated so I restarted them.
I just cherry-picked this PR to the update/further-bugfixes-rc2 branch to get it included in the next release: 1a67dbb |
* Fix image block v6 deprecation (#52822) * Remove incorrect comment * Add missing attribtes and supports * Add integration tests for the deprecation * Fix incorrect import * Fix fixtures * Image: Use the correct method for caption class in recent deprecation (#52853) * Distraction Free: Fix notices in site editor (#52867) * Distraction Free: Add missing command in site editor (#52868) * Site Editor: Fix the template parts link on the list page (#52891) * Return focus more from focus return hook (#52710) * Disambiguate "Import" button string. (#52907) * Disambiguate "Import" button string. * Add _x to import --------- Co-authored-by: Andrew Serong <[email protected]> * My patterns page: Increase color contrast for the toggle group (#52678) * Update style.scss * Update style.scss * Check if object exists before accessing its properties. (#52870) * Check if object exists before accessing its properties. * Name anonymous functions * Update names * Sidebar: Restore Back buton 'go to parent' functionality (#52910) * Global styles revisions: display text if no revisions are found (#52865) * If somehow a user lands on the revisions panel when there are no revisions, show some helpful text rather than a loading spinner. Also, add an E2E test! * Updated unit tests to reflect resolver logic changes * Use existing string * Only open edit view when testing the revisions panel itself * ResizableFrame: Account for window resizing (#52697) * ResizableFrame: Account for window resizing * Don't memoize --------- Co-authored-by: Robert Anderson <[email protected]> * Distraction Free: Fix conflict with showListViewByDefault preference (#52914) * Backporting changes from WordPress/wordpress-develop#4891 * Site Editor: Open template parts in view canvas view mode (#52916) --------- Co-authored-by: Alex Lende <[email protected]> Co-authored-by: George Mamadashvili <[email protected]> Co-authored-by: Andrew Serong <[email protected]> Co-authored-by: Mitchell Austin <[email protected]> Co-authored-by: Jb Audras <[email protected]> Co-authored-by: Carolina Nymark <[email protected]> Co-authored-by: Robert Anderson <[email protected]> Co-authored-by: Ramon <[email protected]> Co-authored-by: Lena Morita <[email protected]> Co-authored-by: ramon <[email protected]>
What?
Fixes #52665. Fixes #52761.
Reverts the key change in #52456 so that the back button will again "go to parent" instead of "go back".
Why?
In #52456 I attempted to fix #50676 by making the back button consistently "go back" (to the previously viewed page) instead of "go to parent".
Unfortunately though this behaviour interacts poorly with the command centre. See #52665 and #52761.
How?
This PR reverts the key change in #52456 which is calling
navigator.goBack()
instead ofnavigator.goToParent()
when the back button is clicked.I did not revert any of the other changes in #52456 which improve the stability of
useSyncPathWithURL
and make theNavigator
API more consistent. I think they make sense to have regardless of what the back button does.Additionally, this PR contains an alternative fix for the original issue #50676. We store a
backPath
string in React History'sstate
when callinggoTo
. This is an object that can hold arbitrary data associated with the new location. Then, when pressing back, we then navigate back to the storedbackPath
if it exists.It's an approach we take elsewhere:
gutenberg/packages/edit-site/src/components/page-template-parts/index.js
Line 44 in b2309e8
gutenberg/packages/edit-site/src/components/page-patterns/patterns-list.js
Lines 128 to 130 in b2309e8
It's not the most elegant fix. I'd prefer to restructure our routes to be more hierarchical as @youknowriad suggests in #52665 (comment). For example, both
/templates/:templateId
and/pages/:pageId/templates/:templateId
would load thewp_template
withid = templateId
but pressing back when viewing the latter would correctly go back to/pages
. I think this is too great of a change to make while 6.3 is in its RC period, though, so I did not opt to do this.Testing Instructions
Test that you cannot reproduce #50676, #52665, or #52761.