Skip to content

My transform variations code partially fulfills its mission #51490

Answered by t-hamano
realthemes asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @realthemes,

I think it is a specification, not a bug, that the innerBlocks is maintained after changing the block variation.

The block editor handbook mentions the following:

innerBlocks (optional, type Array[]) – Initial configuration of nested blocks.

Therefore, I believe the innerBlocks property only defines the template when the block is first inserted.

I haven't tried it, but I think you may explicitly replace innerBlocks template when certain attributes are changed, (i.e., when a variation is changed).

useEffect( () => {
	const newInnerBlocks = [
		// ...
	];

	replaceInnerBlocks( clientId, newInnerBlocks );
}, [ attributes.sidebarPosition ] );

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by realthemes
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@realthemes
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions. [Feature] Block Variations Block variations, including introducing new variations and variations as a feature
2 participants
Converted from issue

This discussion was converted from issue #51458 on June 14, 2023 12:10.