-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 legacy widgets not previewing and widgets saving issue #29111
Conversation
Size Change: +34 B (0%) Total Size: 1.38 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 makes sense to me
It seems this fixes the preview, as it worked predictably now. However I am still able to easily break the widgets editor:
|
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 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
cloneBlocks
to retain the widget id - useBlockSync - uses
cloneBlocks
to retain the widget id - Duplicate blocks - sanitizes so that the duplicate doesn't have the widget id
- Patterns - widgetId won't be defined, so
cloneBlocks
is fine. - Block styles - we don't really care,
cloneBlocks
is fine.
Thanks for fixing @kevin940726, we can separately look at @draganescu's findings.
* 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
* 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
Description
Continued and fix #28379.
useBlockSync
internally usescloneBlock
to sync external changes. However, in a recent change in #28379,cloneBlock
now will sanitize the attributes, which makes__internalWidgetId
to be dropped off whenever the user is making any changes.This PR renames
cloneBlock
to__experimentalCloneSanitizedBlock
(naming TBD) and uses it when duplicating blocks. Then, creates a new methodcloneBlock
that doesn't sanitize attributes, which is essentially the same as the originalcloneBlock
before #28379. This means that the exportedcloneBlock
doesn't have to be breaking anymore.This also fixes an issue where legacy widgets' previews are not being shown correctly, as
__internalWidgetId
was 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: