FIXED - Demo within block editor is affected by duplicate

I often include a little demo of a custom block within the block editor, below the block definition. Thus I can always test if any changes I make to the definition code work out well. Ans if anyone else would like to use the custom block (e.g. as part of a library), the demo is part of the documentation, showing how to use it.

However something strange happens when I make a duplicate of the original block (right-click at the block; select "duplicate block definition"): the demo code with the original block's definition is now calling the duplicate block.

This is not helpful, of course.

  • Is it a known issue?
  • Is it going to be fixed?
  • Is there a workaround I could use in the meantime?

I think that's intended, for recursion purposes.

No, his detached example code isn't part of the original block definition, so isn't involved in its recursion.

I would understand this if it were the other way around, if the sample code in the duplicate block called the original block. But this seems like a definite bug to me.

It is now.

Maybe, eventually?

Well of course you can manually edit the original block. If you mean, can you fix it programmatically, I don't know if there's even a way to get pointers to detached scripts in a Block Editor.

Can you share an example project?

This one.

Update, April 17: the bug appears to be fixed; I removed the demo.

Oh, I see what's happening, and why this is a bug.

Whenever you have a block definition with floating blocks of itself (not attached to any scripts), then when you duplicate a block, those floating blocks with be replaced with the duplicate block.

Take this block for example

When I duplicate this block, I get

Which is fine, until I check the original block's definition

The actual block scripts will not be effected, but floating scripts will be.

Oh. I see. I misread the statement.

Looks like it has already been fixed (I assume v. 9.2.16 was installed earlier today).
Thanks a lot! (@jens, I guess)

The topic may be closed, as far as I'm concerned.