Skip to content

Commit 9552b93

Browse files
tellthemachinesandrewserong
authored andcommitted
Fix error with display of Heading block style variations in style book. (#72551)
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
1 parent 85803c6 commit 9552b93

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

  • packages/edit-site/src/components/style-book

packages/edit-site/src/components/style-book/index.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,29 @@ function applyBlockVariationsToExamples( examples, variation ) {
227227
if ( ! variation ) {
228228
return examples;
229229
}
230-
231-
return examples.map( ( example ) => ( {
232-
...example,
233-
variation,
234-
blocks: {
235-
...example.blocks,
236-
attributes: {
237-
...example.blocks.attributes,
238-
style: undefined,
239-
className: getVariationClassName( variation ),
240-
},
241-
},
242-
} ) );
230+
return examples.map( ( example ) => {
231+
return {
232+
...example,
233+
variation,
234+
blocks: Array.isArray( example.blocks )
235+
? example.blocks.map( ( block ) => ( {
236+
...block,
237+
attributes: {
238+
...block.attributes,
239+
style: undefined,
240+
className: getVariationClassName( variation ),
241+
},
242+
} ) )
243+
: {
244+
...example.blocks,
245+
attributes: {
246+
...example.blocks.attributes,
247+
style: undefined,
248+
className: getVariationClassName( variation ),
249+
},
250+
},
251+
};
252+
} );
243253
}
244254

245255
function StyleBook( {

0 commit comments

Comments
 (0)