Skip to content

Commit 157517c

Browse files
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 8501118 commit 157517c

File tree

1 file changed

+23
-13
lines changed
  • packages/edit-site/src/components/style-book

1 file changed

+23
-13
lines changed

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

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

242252
function StyleBook( {

0 commit comments

Comments
 (0)