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

When an empty legacy widget is added the widget area can't be saved #28561

Closed
draganescu opened this issue Jan 28, 2021 · 3 comments · Fixed by #32359
Closed

When an empty legacy widget is added the widget area can't be saved #28561

draganescu opened this issue Jan 28, 2021 · 3 comments · Fixed by #32359
Assignees
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@draganescu
Copy link
Contributor

Steps to reproduce:

  • have the current master of Gutenberg
  • have a default WordPress install with no extra plugins
  • go to Appearance -> Widgets
  • at the end of a widget area add a legacy widget block
    • the legacy widget block should say there are no available widgets
  • save the page
  • see the error

Screenshots

widgets-legacy-no-save.mp4
@draganescu draganescu added the [Type] Bug An existing feature does not function as intended label Jan 28, 2021
@Soean Soean added the [Feature] Widgets Screen The block-based screen that replaced widgets.php. label Jan 30, 2021
@tellthemachines
Copy link
Contributor

This looks like the same error as #31249

@noisysocks
Copy link
Member

noisysocks commented May 5, 2021

We can fix this the same way we did in the Customzier by converting the Legacy Widget block to a block widget when it is empty.

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

While we're at it, we should move blockToWidget and widgetToBlock to @wordpress/widgets so that we're not defining the same functions in both edit-widgets and customize-widgets.

@noisysocks noisysocks self-assigned this Jun 1, 2021
@noisysocks
Copy link
Member

While we're at it, we should move blockToWidget and widgetToBlock to @wordpress/widgets so that we're not defining the same functions in both edit-widgets and customize-widgets.

Hm, can't really do this as they're different implementations. In @wordpress/customize-widgets we are mapping from blocks ↔ how widgets are represented in the Customizer. In @wordpress/edit-widgets we are mapping form blocks ↔ how widgets are represented in the REST API. They aren't the same unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants