-
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
Global styles revisions: ensure redirect runs once for back button #51316
Global styles revisions: ensure redirect runs once for back button #51316
Conversation
…d to ensure the internal functions are run once, and as intendted
@andrewserong @ndiego Do you think this should be included in the next release? Assuming that #51149 made it in, so we'd need to correct it. I'll add the label just in case. |
Yes, it'd be great to include this one. Just taking it for a spin 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.
Thanks for the quick fix @ramonjd! This logic looks good to me — we only want this section to fire when editorCanvasContainerView
changes, and when that change occurs, we want to reference the location path at the time of that change 👍
All working nicely:
✅ Clicking the revisions link in the browse mode Styles screen correctly opens Revisions
✅ Revisions back button now works as intended
✅ From the Revisions screen, opening the Style Book changes the canvas container and redirects
✅ Opening and closing the Style Book works as before with no unexpected redirects
✅ Style book icon in browse mode Styles screen still works, and clicking the preview with the Style book open persists the container state in edit mode
LGTM! ✨
Size Change: -3 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
…51316) * Removing location?.path from the dependency to avoid infinite loop and to ensure the internal functions are run once, and as intendted * Add disable lint rule
…ordPress#51316) * Removing location?.path from the dependency to avoid infinite loop and to ensure the internal functions are run once, and as intendted * Add disable lint rule
What?
I can't click the back button on the global styles revisions panel!

Why?
The
useEffect
callback in GlobalStylesEditorCanvasContainerLink is triggered every timelocation?.path
changes. So when the path changes andeditorCanvasContainerView === 'global-styles-revisions'
is alreadytrue
it'll try to executegoTo( '/revisions' )
again. Woot!How?
Removing
location?.path
from the dependency to avoid infinite loop and to ensure the internal functions are run once, and as intendedTesting Instructions