Skip to content

Commit 430a9c0

Browse files
mirkaciampo
andauthored
ComboboxControl: Add flag to remove bottom margin (#43165)
* ComboboxControl: Add flag to remove bottom margin * Use Action for value inspection in story * Add changelog * Add optional chaining for onChange Co-authored-by: Marco Ciampini <[email protected]> Co-authored-by: Marco Ciampini <[email protected]>
1 parent 1cd4c46 commit 430a9c0

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

packages/components/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
- `BoxControl`: Export `applyValueToSides` util function. ([#42733](https://github.com/WordPress/gutenberg/pull/42733/)).
4747
- `ColorPalette`: use index while iterating over color entries to avoid React "duplicated key" warning ([#43096](https://github.com/WordPress/gutenberg/pull/43096)).
4848
- `AnglePickerControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#43160](https://github.com/WordPress/gutenberg/pull/43160/)).
49+
- `ComboboxControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#43165](https://github.com/WordPress/gutenberg/pull/43165/)).
4950

5051
### Internal
5152

packages/components/src/combobox-control/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const DetectOutside = withFocusOutside(
4646
);
4747

4848
function ComboboxControl( {
49+
/** Start opting into the new margin-free styles that will become the default in a future version. */
50+
__nextHasNoMarginBottom = false,
4951
__next36pxDefaultSize,
5052
value: valueProp,
5153
label,
@@ -220,6 +222,7 @@ function ComboboxControl( {
220222
return (
221223
<DetectOutside onFocusOutside={ onFocusOutside }>
222224
<BaseControl
225+
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
223226
className={ classnames(
224227
className,
225228
'components-combobox-control'

packages/components/src/combobox-control/stories/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ const countries = [
257257
export default {
258258
title: 'Components/ComboboxControl',
259259
component: ComboboxControl,
260+
argTypes: {
261+
__nextHasNoMarginBottom: { control: { type: 'boolean' } },
262+
onChange: { action: 'onChange' },
263+
},
260264
};
261265

262266
const mapCountryOption = ( country ) => ( {
@@ -266,17 +270,19 @@ const mapCountryOption = ( country ) => ( {
266270

267271
const countryOptions = countries.map( mapCountryOption );
268272

269-
function Template( args ) {
273+
function Template( { onChange, ...args } ) {
270274
const [ value, setValue ] = useState( null );
271275

272276
return (
273277
<>
274278
<ComboboxControl
275279
{ ...args }
276280
value={ value }
277-
onChange={ setValue }
281+
onChange={ ( ...changeArgs ) => {
282+
setValue( ...changeArgs );
283+
onChange?.( ...changeArgs );
284+
} }
278285
/>
279-
<p>Value: { value }</p>
280286
</>
281287
);
282288
}

packages/components/src/combobox-control/style.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ input.components-combobox-control__input[type="text"] {
3131
flex-wrap: wrap;
3232
align-items: flex-start;
3333
width: 100%;
34-
margin: 0 0 $grid-unit-10 0;
3534
padding: 0;
3635

3736
&:focus-within {

0 commit comments

Comments
 (0)