WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.58k stars 4.23k forks source link

Duplicates, triplicates, quadruplicates widgets.. into the Legacy widget's block selectbox #32019

Closed imath closed 3 years ago

imath commented 3 years ago

Description

Hi, First congrats for the work achieved so far about the Widget Block Editor. I've started working on migrating the BuddyPress Legacy widgets. So far it's going great. I just noticed something weird about legacy widget block: the select box is listing more than once widgets as soon as you add/remove a widget.

Step-by-step reproduction instructions

  1. Download BuddyPress trunk (a fix has been added to avoid the use of get_current_screen() function to cause a fatal into the new Widget Block editor screen).
  2. Rename the unzip folder to buddypress
  3. Install & Activate BuddyPress
  4. Go to the new Widget Block editor screen
  5. Add a legacy widget block
  6. Select one of the BuddyPress widgets
  7. Update the Widgets
  8. Remove the just added BuddyPress widget
  9. Update the Widgets
  10. Refresh the page
  11. Add a new Legacy Widget block, now the select box contains 2 duplicate options for the BuddyPress widget you added/removed.

Expected behaviour

Only list a widget once into the select box of the Legacy widget block

Actual behaviour

Duplicates as soon as you add/remove a legacy widget

Screenshots or screen recording (optional)

dupes

WordPress information

Device information

tellthemachines commented 3 years ago

I can reproduce this with both WooCommerce and SiteOrigin widgets, but only on the second delete. So my steps are:

  1. Add a legacy widget, save page, delete widget.
  2. Refresh the page, repeat process with same widget.
  3. Refresh the page again and verify that widget is repeated in the legacy widget block dropdown.

I can also reproduce the issue by adding two identical legacy widgets in the same widget area, saving and refreshing the page.

Deleting all widgets (including inactive) from the old widgets screen fixes the issue.

noisysocks commented 3 years ago

Thanks for the report! This is due to a REST API bug which will need to be fixed in core now that that code has been merged. I've opened https://core.trac.wordpress.org/ticket/53305.