Fix legacy widgets not previewing and widgets saving issue#29111
Merged
Fix legacy widgets not previewing and widgets saving issue#29111
Conversation
|
Size Change: +34 B (0%) Total Size: 1.38 MB
ℹ️ View Unchanged
|
kevin940726
commented
Feb 19, 2021
talldan
reviewed
Feb 19, 2021
youknowriad
reviewed
Feb 19, 2021
Contributor
youknowriad
left a comment
There was a problem hiding this comment.
This makes sense to me
Contributor
|
It seems this fixes the preview, as it worked predictably now. However I am still able to easily break the widgets editor:
|
talldan
approved these changes
Feb 22, 2021
Contributor
talldan
left a comment
There was a problem hiding this comment.
It makes sense to avoid the breaking change to the API in the upcoming version of WordPress.
I went over the uses of cloneBlocks and the changes in this PR look correct:
- Merging blocks - uses
cloneBlocksto retain the widget id - useBlockSync - uses
cloneBlocksto retain the widget id - Duplicate blocks - sanitizes so that the duplicate doesn't have the widget id
- Patterns - widgetId won't be defined, so
cloneBlocksis fine. - Block styles - we don't really care,
cloneBlocksis fine.
Thanks for fixing @kevin940726, we can separately look at @draganescu's findings.
noisysocks
pushed a commit
that referenced
this pull request
Feb 22, 2021
* Fix editing blocks in widgets screen by introducing duplicateBlock in useBlockSync * Update e2e test * Add test for displaying legacy widgets * Fix test * Rename to __experimentalCloneSanitizedBlock * Update changelog
noisysocks
pushed a commit
that referenced
this pull request
Feb 22, 2021
* Fix editing blocks in widgets screen by introducing duplicateBlock in useBlockSync * Update e2e test * Add test for displaying legacy widgets * Fix test * Rename to __experimentalCloneSanitizedBlock * Update changelog
7 tasks
6 tasks
7 tasks
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.
Description
Continued and fix #28379.
useBlockSyncinternally usescloneBlockto sync external changes. However, in a recent change in #28379,cloneBlocknow will sanitize the attributes, which makes__internalWidgetIdto be dropped off whenever the user is making any changes.This PR renames
cloneBlockto__experimentalCloneSanitizedBlock(naming TBD) and uses it when duplicating blocks. Then, creates a new methodcloneBlockthat doesn't sanitize attributes, which is essentially the same as the originalcloneBlockbefore #28379. This means that the exportedcloneBlockdoesn't have to be breaking anymore.This also fixes an issue where legacy widgets' previews are not being shown correctly, as
__internalWidgetIdwas not being passed to the block before.How has this been tested?
Updated e2e test for duplicating blocks, and added e2e test for displaying legacy widgets' previews.
Types of changes
Breaking change
Checklist: