File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
packages/edit-widgets/src/store Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,15 @@ export function* saveWidgetArea( widgetAreaId ) {
108108 ( { sidebar } ) => sidebar === widgetAreaId
109109 ) ;
110110
111- // Remove all duplicate reference widget instances
111+ // Remove all duplicate reference widget instances for legacy widgets.
112+ // Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget
113+ // implemented using a function. WordPress doesn't support having more than one instance of these, if you try to
114+ // save multiple instances of these in different sidebars you will run into undefined behaviors.
112115 const usedReferenceWidgets = [ ] ;
113- const widgetsBlocks = post . blocks . filter ( ( { attributes : { id } } ) => {
114- if ( id ) {
116+ const widgetsBlocks = post . blocks . filter ( ( block ) => {
117+ const { id } = block . attributes ;
118+
119+ if ( block . name === 'core/legacy-widget' && id ) {
115120 if ( usedReferenceWidgets . includes ( id ) ) {
116121 return false ;
117122 }
You can’t perform that action at this time.
0 commit comments