Skip to content

Commit

Permalink
Set the toolbar dropdown menu variant in the toolbar component via th…
Browse files Browse the repository at this point in the history
…e context system
  • Loading branch information
ciampo committed May 31, 2023
1 parent b1a871d commit 8e711f9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions packages/components/src/toolbar/toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ import deprecated from '@wordpress/deprecated';
import ToolbarGroup from '../toolbar-group';
import ToolbarContainer from './toolbar-container';
import type { ToolbarProps } from './types';
import type { WordPressComponentProps } from '../../ui/context';
import {
WordPressComponentProps,
ContextSystemProvider,
} from '../../ui/context';

const CONTEXT_SYSTEM_VALUE = {
DropdownMenu: {
// Note: the legacy `DropdownMenu` component is not yet reactive to this
// context variant. See https://github.com/WordPress/gutenberg/pull/51097.
variant: 'toolbar',
},
};

function UnforwardedToolbar(
{
Expand All @@ -40,12 +51,14 @@ function UnforwardedToolbar(
className
);
return (
<ToolbarContainer
className={ finalClassName }
label={ label }
ref={ ref }
{ ...props }
/>
<ContextSystemProvider value={ CONTEXT_SYSTEM_VALUE }>
<ToolbarContainer
className={ finalClassName }
label={ label }
ref={ ref }
{ ...props }
/>
</ContextSystemProvider>
);
}

Expand Down

0 comments on commit 8e711f9

Please sign in to comment.