Class is not applied to the element after duplicating the element with a shortcut

Duplicating an element that has a custom class applied with the help of the shortcut (Command + Shift + D) does not copy the class to the element.

Demonstration can be seen in this short video:

Environment info

  • WordPress version: 6.0
  • Gutenberg Plugin version: -
  • Cwicly Plugin version:
  • Cwicly Theme version: 1.0.3

Hi @Dev.tomi,

Thanks for bringing this up.
Indeed, this behaviour is correct (when using the shortcut), since the block class must be unique, since we’re able to hook into the shortcut for duplication, we process a change for the Class and ID.

If you want that same class to be applied, the additional class field would be more appropriate.

Why does the block class have to be unique?
I’m not sure if you have noticed, but whenever you apply a class from one block to another, whether it is on the same page or on a different post/template, if you change the original class name for that block, the additional class in the block you added the original class to is automatically updated with the new class name.
With most builders out there, you would have to manually go round and modify every instance in which that class name appears.

More precisely, block class names are intimately linked to their specific block, which is why using Gutenberg’s duplication process will mess things up along the way, and is not recommended.

Thank you for explanation @Louis

What about using CSS Naming Conventions or Frameworks in terms of copying blocks, also to other sites?
As far as I understand it, it wouldn’t be the best best using Cwicly?
Just a simple question to be sure I got it.

Some thoughts:

  • We do have the Navigator to name our blocks properly, so this could act like a Naming Convention. But that’s still a bit confusing when inspecting the code, also in terms of the possibitly to export the code as HTML in the future.
  • Framworks would be a case for the additional class field anyway, so it will get copied properly in any case?

Maybe I can get some input here.
Thanks in advance.