-
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
Fix browser history when synchronising state with urls #48731
Conversation
Seems to fix the issue on my end! Nice one @youknowriad! Out of curiosity, on a separate note (not caused by this PR), when I click "Template Parts" and click "Footer", for example, I need to click the browser's back button twice to actually go back. Is this related or a separate issue? |
Size Change: +710 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
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 partially fixes the reported issue, but when I navigate around in Site Editor and then use the Back button, I end up with wp-admin/site-editor.php?canvas=init&path=%2Fwp_template%2Ftwentytwentythree%252F%252Fhome
URL, which produces white screen.
@Mamaduka I can't reproduce this myself. Do you have some steps I could follow to see if I can reproduce? |
@Mamaduka which browser are you using? |
I can reproduce this issue, it seems there's still an extra history.push. Let's see if I can find it. |
My bad! It looks like this was a browser cache issue. Sorry for the confusion. P.S. I'm testing with Chrome. |
It turns out that when you do |
While the previous fix works, I'm also exploring if I can change how "push" works instead. |
85f2370 fixes the double back button issue but also appears to flash the "Home" submenu briefly. |
@@ -32,7 +32,6 @@ export default function TemplateDetails( { template, onClose } ) { | |||
|
|||
// TODO: We should update this to filter by template part's areas as well. | |||
const browseAllLinkProps = useLink( { | |||
canvas: 'view', |
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 this causes regression of #48301.
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.
it should be "undefined" now because "view" is the default value. But I guess it suffers from the issue I talk about here #48731 (comment)
@youknowriad, I also noticed that if I refresh |
Ok, I think I've fixed all the issues. I'm not entirely satisfied with these syncing hooks and I believe we need e2e tests for all these flows but this should be good maybe for now? |
This is working perfectly when going straight from the dashboard to the site editor then hitting the back button. One thing I noticed is when you go dashboard > site editor > [back to templates sidebar view] then try the browser back button, there's a couple of extra dead back button clicks in there between the site editor and the dashboard. I tried to capture it in this gif: |
@apeatling Noticing that too when I do the following:
I'm also still noticing the flash of the "Home" sidebar view when I do the following:
|
I think I fixed both of these issues. I'd appreciate some checks. @apeatling I also noticed that on your video you land directly on a sub menu when opening the site editor. I'm aware of this issue but it's specific to old WP versions (there's a redirect that we can't override in Gutenberg). If you test with WP trunk, you'll notice that you land on the "root" of the site editor. |
packages/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js
Outdated
Show resolved
Hide resolved
I added some e2e tests to cover these flows. |
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've tested this PR quite a lot and everything seems to work well. Thanks Riad!
packages/edit-site/src/components/sidebar-navigation-screen-templates/index.js
Outdated
Show resolved
Hide resolved
Flaky tests detected in ee28018. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4341886921
|
I just cherry-picked this PR to the wp/6.2 branch to get it included in the next release: e064813 |
closes #48726
What?
This PRs fixes the browser history when navigating the site editor.
How?
Testing Instructions
1- Open the site editor
2- Click browser "back" button
3- you should be back in the dashboard properly
4- Testing using Chrome, Firefox or Edge (in trunk it's broken with these)