Skip to content
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

Widgets editor: Fix error when saving empty Legacy Widget block #32359

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions packages/edit-widgets/src/store/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export function transformWidgetToBlock( widget ) {
export function transformBlockToWidget( block, relatedWidget = {} ) {
let widget;

if ( block.name === 'core/legacy-widget' ) {
const isValidLegacyWidgetBlock =
block.name === 'core/legacy-widget' &&
( block.attributes.id || block.attributes.instance );

if ( isValidLegacyWidgetBlock ) {
widget = {
...relatedWidget,
id: block.attributes.id ?? relatedWidget.id,
Expand All @@ -56,13 +60,6 @@ export function transformBlockToWidget( block, relatedWidget = {} ) {
};
}

// Delete deprecated properties.
delete widget.description;
delete widget.name;
delete widget.number;
delete widget.settings;
delete widget.widget_class;
Copy link
Member Author

@noisysocks noisysocks Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed these in #30853 🙂


// Delete read-only properties.
delete widget.rendered;
delete widget.rendered_form;
Expand Down