Block Theme Preview: Display loading state when activating#55658
Merged
okmttdhr merged 1 commit intoWordPress:trunkfrom Nov 2, 2023
Merged
Conversation
okmttdhr
approved these changes
Nov 1, 2023
Contributor
There was a problem hiding this comment.
This change looks good to me 👍
@scruffian Could you leave a comment, if any? Otherwise, I'll just merge it 🙂
Comment on lines
+36
to
41
| startResolution( 'activateTheme' ); | ||
| await window.fetch( activationURL ); | ||
| finishResolution( 'activateTheme' ); | ||
| const { wp_theme_preview: themePreview, ...params } = | ||
| location.params; | ||
| history.replace( params ); |
Contributor
There was a problem hiding this comment.
Outside the scope of this PR, but it's worth noting that history.replace (which removes ?wp_theme_preview=) is executed regardless of the HTTP status returned by window.fetch, including a 500 error 😇 CC: @scruffian
scruffian
reviewed
Nov 1, 2023
Contributor
scruffian
left a comment
There was a problem hiding this comment.
This change looks good, although I've not tested. Happy for you to merge if you're also happy with it :)
3 tasks
This was referenced Nov 29, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
We want to display the loading state when people are previewing the theme and activating it.
Why?
Resolved #55273
How?
Use
startResolution&finishResolutionto record we're activating the theme. I'm not sure whether it's a good idea but it's simple enough and provides a better experience. Additionally, we can keep using the same way when we have the rest API to activate the theme.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
btp-activate-1.mov
btp-activate-2.mov