Skip to content

Allow parent blocks to expose specific child toolbar controls - #80246

Closed
scruffian wants to merge 9 commits into
trunkfrom
agent/granular-child-controls
Closed

scruffian wants to merge 9 commits into
trunkfrom
agent/granular-child-controls

Conversation

@scruffian

@scruffian scruffian commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

What?

Adds granular control over which parent block toolbar controls are exposed when a child block is selected.

Parent blocks can keep using supports.__experimentalExposeControlsToChildren: true to expose every control that opts into child sharing. They can now also pass an allow-list, for example supports.__experimentalExposeControlsToChildren: [ 'media' ], and controls can opt into that list with __experimentalShareWithChildBlocks="media".

This also updates the Playlist block to use the new granular behavior so its Add media control is owned by the parent Playlist block while still appearing for selected Playlist Track children.

Why?

Some parent blocks need to share one specific toolbar control with child blocks without exposing every parent control that has opted into child sharing.

For Playlist, this avoids plumbing the add-tracks callback through child block context just so each Playlist Track can render the parent's Add control.

How?

  • Carries the raw __experimentalExposeControlsToChildren support value through block edit context as either true, an allow-list, or false.
  • Allows BlockControls fills to name shared child controls with __experimentalShareWithChildBlocks="name".
  • Checks named controls against the parent allow-list before rendering them in the child toolbar slot.
  • Captures child toolbars when the parent exposes all controls or a non-empty allow-list.
  • Moves Playlist's Add media toolbar control back to the parent Playlist block and exposes only the media control to child tracks.

Testing Instructions

Automated tests

Run:

npm run test:unit -- packages/block-editor/src/components/block-controls/test/index.js packages/block-editor/src/components/inner-blocks/test/index.js packages/block-library/src/playlist/test/edit-component.js

Confirm all suites pass.

Manual smoke test: legacy boolean behavior

  1. Start the environment if it is not already running:

    npm run wp-env status
    npm run wp-env start
  2. Open the editor and insert a parent block that already uses supports.__experimentalExposeControlsToChildren: true, such as Buttons.

  3. Select a child block inside that parent, such as an individual Button block.

  4. Confirm the parent toolbar controls that were previously shared with child blocks are still available.

  5. Select the parent block directly and confirm its own toolbar controls still render as expected.

Manual smoke test: Playlist granular behavior

  1. Open the editor and insert a Playlist block with at least one track.
  2. Select an individual Playlist Track child block.
  3. Confirm the Add media control appears in the child toolbar.
  4. Confirm unrelated parent toolbar controls are not exposed to the Playlist Track child toolbar.

Screenshots

Note that now the playlist track toolbar appears in the same place as the playlist block toolbar:
Screenshot 2026-07-15 at 15 13 48

Note

We should remove the playlist specific commit from the PR (9f8a5bf). This is just for testing.

Automated Tests Run

  • npm run test:unit -- packages/block-editor/src/components/block-controls/test/index.js packages/block-editor/src/components/inner-blocks/test/index.js packages/block-library/src/playlist/test/edit-component.js

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Size Change: +52 B (0%)

Total Size: 7.72 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 422 kB +64 B (+0.02%)
build/scripts/block-library/index.min.js 351 kB -12 B (0%)

compressed-size-action

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Flaky tests detected in 479392d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29439955199
📝 Reported issues:

@scruffian
scruffian force-pushed the agent/granular-child-controls branch from f82297b to 9812979 Compare July 15, 2026 10:10
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jul 15, 2026
@scruffian
scruffian force-pushed the agent/granular-child-controls branch from 9812979 to 9f8a5bf Compare July 15, 2026 10:40
Comment thread packages/block-editor/src/components/block-list/block.js Outdated
@scruffian scruffian changed the title Add granular child toolbar controls Allow parent blocks to expose specific child toolbar controls Jul 15, 2026
@scruffian scruffian self-assigned this Jul 15, 2026
@scruffian scruffian added the [Type] Enhancement A suggestion for improvement. label Jul 15, 2026
@scruffian
scruffian marked this pull request as ready for review July 15, 2026 14:23
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jeryj jeryj left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

playlist track block showing alignment controls

I don't think this is working as intended. The alignment control is also being passed down through to the child track.

Also, I'm unsure about the overall API design here. Even if it does work as intended, the Add button has to go in it's own toolbar group, and I'm not sure that's the final design we'd want. I assumed it would go in the same group as "Add"

@scruffian
scruffian force-pushed the agent/granular-child-controls branch from 1383e74 to 8bbfa94 Compare July 16, 2026 11:04
@scruffian

Copy link
Copy Markdown
Contributor Author

I don't think this is working as intended. The alignment control is also being passed down through to the child track.

You're right. I've fixed this.

@scruffian

Copy link
Copy Markdown
Contributor Author

Also, I'm unsure about the overall API design here. Even if it does work as intended, the Add button has to go in it's own toolbar group, and I'm not sure that's the final design we'd want. I assumed it would go in the same group as "Add"

Do you mean:

I assumed it would go in the same group as "Replace"?

I think it makes sense to be in its own group, since this action relates to the parent block. This is a question for @fcoveram and @jasmussen:

We already have a feature that allows parent blocks to optionally share their toolbars with child blocks - the buttons block is an example. This PR brings in the ability for parent blocks to decide which parts of the toolbar to share - rather than sharing all controls:

  1. Do you think this is a valuable addition?
  2. If so, does it make sense for the parent controls to go into a different "group" than the child block controls?

Thanks!

@jeryj

jeryj commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I assumed it would go in the same group as "Replace"?

Yes, sorry. I thought they would go in the same group since they're about modifying the track list. I can see why the parent tools passed down should be in their own group for clarity.

@jeryj

jeryj commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@scruffian Is the specific issue here that the alignment control gets passed through to the child, and you don't want that one to show? I think it might be fine for the alignment control to get passed through. It's pretty hard to discover anyways. And the playlist track block isn't full of custom controls, so I think it would be fine to just add __experimentalExposeControlsToChildren supports.

@scruffian

Copy link
Copy Markdown
Contributor Author

Yes that was the issue i was trying to solve. Maybe you're right, we can just use __experimentalExposeControlsToChildren

@scruffian

Copy link
Copy Markdown
Contributor Author

I'm doing that in #80368

@jeryj

jeryj commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Closing in favor of #80368

@jeryj jeryj closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants