Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComboboxControl: Add flag to remove bottom margin #43165

Merged
merged 4 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- `BaseControl`: Add `box-sizing` reset style ([#42889](https://github.com/WordPress/gutenberg/pull/42889)).
- `BoxControl`: Export `applyValueToSides` util function. ([#42733](https://github.com/WordPress/gutenberg/pull/42733/)).
- `AnglePickerControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#43160](https://github.com/WordPress/gutenberg/pull/43160/)).
- `ComboboxControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#43165](https://github.com/WordPress/gutenberg/pull/43165/)).

### Internal

Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/combobox-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const DetectOutside = withFocusOutside(
);

function ComboboxControl( {
/** Start opting into the new margin-free styles that will become the default in a future version. */
__nextHasNoMarginBottom = false,
__next36pxDefaultSize,
value: valueProp,
label,
Expand Down Expand Up @@ -222,6 +224,7 @@ function ComboboxControl( {
return (
<DetectOutside onFocusOutside={ onFocusOutside }>
<BaseControl
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
className={ classnames(
className,
'components-combobox-control'
Expand Down
12 changes: 9 additions & 3 deletions packages/components/src/combobox-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ const countries = [
export default {
title: 'Components/ComboboxControl',
component: ComboboxControl,
argTypes: {
__nextHasNoMarginBottom: { control: { type: 'boolean' } },
onChange: { action: 'onChange' },
},
};

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

const countryOptions = countries.map( mapCountryOption );

function Template( args ) {
function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState( null );

return (
<>
<ComboboxControl
{ ...args }
value={ value }
onChange={ setValue }
onChange={ ( ...changeArgs ) => {
setValue( ...changeArgs );
onChange( ...changeArgs );
mirka marked this conversation as resolved.
Show resolved Hide resolved
} }
/>
<p>Value: { value }</p>
Copy link
Member Author

Choose a reason for hiding this comment

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

Added an onChange action so we can remove this value inspector thingy.

</>
);
}
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/combobox-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ input.components-combobox-control__input[type="text"] {
flex-wrap: wrap;
align-items: flex-start;
width: 100%;
margin: 0 0 $grid-unit-10 0;
padding: 0;

&:focus-within {
Expand Down