diff --git a/packages/block-editor/src/components/provider/index.js b/packages/block-editor/src/components/provider/index.js index 0fa3f042053d0..c3a87dfb5ff00 100644 --- a/packages/block-editor/src/components/provider/index.js +++ b/packages/block-editor/src/components/provider/index.js @@ -45,7 +45,7 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider( useBlockSync( props ); return ( - + { children } diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 01a31c58d01c8..659fafc9d1c5a 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -19,6 +19,7 @@ - `ToggleGroupControl`: react correctly to external controlled updates ([#56678](https://github.com/WordPress/gutenberg/pull/56678)). - `ToolsPanel`: fix a performance issue ([#56770](https://github.com/WordPress/gutenberg/pull/56770)). - `BorderControl`: adjust `BorderControlDropdown` Button size to fix misaligned border ([#56730](https://github.com/WordPress/gutenberg/pull/56730)). +- `SlotFillProvider`: Restore contextual Slot/Fills within SlotFillProvider ([#56779](https://github.com/WordPress/gutenberg/pull/56779)). ### Internal diff --git a/packages/components/src/slot-fill/index.tsx b/packages/components/src/slot-fill/index.tsx index fb1a08bc2207f..b2df054973a5b 100644 --- a/packages/components/src/slot-fill/index.tsx +++ b/packages/components/src/slot-fill/index.tsx @@ -55,9 +55,12 @@ export function UnforwardedSlot( } export const Slot = forwardRef( UnforwardedSlot ); -export function Provider( { children }: SlotFillProviderProps ) { +export function Provider( { + children, + passthrough = false, +}: SlotFillProviderProps ) { const parent = useContext( SlotFillContext ); - if ( ! parent.isDefault ) { + if ( ! parent.isDefault && passthrough ) { return <>{ children }; } return ( diff --git a/packages/components/src/slot-fill/types.ts b/packages/components/src/slot-fill/types.ts index 8abb9b941c527..f3a8f2255f287 100644 --- a/packages/components/src/slot-fill/types.ts +++ b/packages/components/src/slot-fill/types.ts @@ -96,6 +96,11 @@ export type SlotFillProviderProps = { * The children elements. */ children: ReactNode; + + /** + * Whether to pass slots to the parent provider if existent. + */ + passthrough?: boolean; }; export type SlotFillBubblesVirtuallySlotRef = RefObject< HTMLElement >;