Skip to content

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

Closed

Description

@mikachan

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.

Activity

  1. added
    [Feature] Nested / Inner BlocksAnything related to the experience of nested/inner blocks inside a larger container, like Group or P
    on Sep 19, 2024
  2. andrewserong commented on Sep 20, 2024

    @andrewserong
    Contributor

    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 #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:

    2024-09-20.10.49.53.mp4
  3. mikachan commented on Sep 20, 2024

    @mikachan
    MemberAuthor

    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!

  4. changed the title [-]Button Inner Blocks: Allow buttons to inherit styling from existing inner blocks[/-] [+]Button Inner Blocks: Allow buttons to inherit styling from existing inner blocks when pressing enter[/+] on Sep 20, 2024
  5. youknowriad commented on Oct 21, 2026

    @youknowriad
    Contributor

    Thanks for writing this up, @mikachan. This now works in trunk: #81250 unified what a new sibling block inherits, so pressing Enter in a styled button creates a new button with the same styling (everything except its text and metadata), just like the inserter and the appender. I checked it on a current trunk build with a pattern-style button, and the new button kept its colors, font size, border radius and weight. Closing as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] ButtonsAffects the Buttons Block[Feature] Nested / Inner BlocksAnything related to the experience of nested/inner blocks inside a larger container, like Group or P[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions