WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Button Inner Blocks: Allow buttons to inherit styling from existing inner blocks when pressing enter #65496

Open mikachan opened 1 month ago

mikachan commented 1 month ago

What problem does this address?

When a pattern is inserted that includes a Button block with specific styling, any additional buttons that are added when pressing enter after inserting the pattern do not automatically inherit the styling from the pattern. This means the new buttons do not match the intended pattern styling.

For example, when inserting the Heading, Paragraph, Button with Two Images pattern and then adding more buttons next to the existing "Sign up" button, the buttons will not match the pattern styling:

image

(I was using TT4 theme when testing this.)

What is your proposed solution?

Add the ability for an already styled inner block to share its styling with sibling inner blocks easily, ideally automatically. We should still allow users to customise individual inner blocks as usual.

andrewserong commented 1 month ago

Thanks for writing this up!

I think we have this behaviour partially implemented. But only when clicking on the inserter? I remember working on it back in https://github.com/WordPress/gutenberg/pull/37905, but it's been so long ago now, looking at that PR it's as if someone else wrote it 😆

In testing in trunk I can see that if I click the inserter, then the styles get copied across as expected. If, however, I press the enter key to create a new button block, the behaviour to copy the block attributes does not apply. As described in this issue, I think it should. Here's how it's looking to me:

https://github.com/user-attachments/assets/39e3ca24-37d4-4c94-9f34-7bb17f5aa223

mikachan commented 1 month ago

In testing in trunk I can see that if I click the inserter, then the styles get copied across as expected.

Ah yes, I can see that's how it's working for me too. So it's only if you press enter to insert a new block. I'll update the issue, thank you!