-
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
Preserve the wp_theme_preview query arg when navigating in Site Editor #61394
Conversation
@@ -82,9 +75,6 @@ export default function LeafMoreMenu( props ) { | |||
{ | |||
postType: 'page', | |||
postId: attributes.id, | |||
...( isPreviewingTheme() && { | |||
wp_theme_preview: currentlyPreviewingTheme(), | |||
} ), |
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.
Preserving wp_theme_preview
no longer needs to be done explicitly like this. It is now, and should continue to be, abstracted and automated.
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.
Does this place need to remove the param management?
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.
That useLink
function is also creating a URL link that can be used as an <a href>
attribute. Therefore the wp_theme_preview
arg needs to be added explicitly, there is no router magic that would add it automatically. That's why I'm keeping it here.
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. |
Size Change: +27 B (0%) Total Size: 1.74 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.
Tested and it works for restoring the theme preview functionality. Left one comment, not sure if it causes any issue.
So the router should maybe get a setting that contains what params need to be sticky, or are externally "managed"?
@@ -82,9 +75,6 @@ export default function LeafMoreMenu( props ) { | |||
{ | |||
postType: 'page', | |||
postId: attributes.id, | |||
...( isPreviewingTheme() && { | |||
wp_theme_preview: currentlyPreviewingTheme(), | |||
} ), |
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.
Does this place need to remove the param management?
We'll need to think more deeply about what is the best long term solution for this. If the router has a "sticky params" setting, they need to somehow find their way also to the URLs that are not processed by the router. See the I plan to continue working on this, this PR is just a good-enough hotfix so that the Theme Preview feature is not broken for too long. |
Apparently I broke e2e tests, like this one:
There are links that have an empty |
ad13f80
to
4180577
Compare
@draganescu I fixed the e2e failures (caused by bad |
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.
Let's get this in as it fixes the big problem.
Stumbled upon another smaller problem, which may have been in before any change:
- when previewing
- after activating a theme
- clicking browser back
- brings the activate button back, which is wrong b/c the theme is already active
⬆️ this needs to be a separate issue, not blocking here.
Thank you for the quick help @jsnajdr
Nice find, though in this case it's not a regression caused by #60466, it existed before. If you click browser back button after theme activation, the URL changes from one that doesn't have A possible fix is to detect the case where we're previewing the currently active theme. In that case all the "Activate ..." buttons have no function and we should be redirected to plain Site Editor, without |
Fixes #61239, a bug where the
wp_theme_preview
query param is not preserved when navigating around Site Editor in "Activate theme" mode.It's a regression I commited in #60466, stopping to preserve query params automatically.
This fix is a not very good "temporary" hotfix. It's not a good solution to patch the router package, but I haven't found any other so far and I want to make the feature work again quickly.
How to test:
wp_theme_preview=theme-slug
query param.