Skip to content

Commit

Permalink
ComboboxControl : Deprecate 36px default size (#66900)
Browse files Browse the repository at this point in the history
* Add the console warning for 36px size variation

* Add the changelog for the deprecation

* Update: changelog and JSDoc

---------

Co-authored-by: PARTHVATALIYA <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent dea308b commit fbc8c9f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
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 @@
### Deprecations

- `Radio`: Deprecate 36px default size ([#66572](https://github.com/WordPress/gutenberg/pull/66572)).
- `ComboboxControl`: Deprecate 36px default size ([#66900](https://github.com/WordPress/gutenberg/pull/66900)).

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/combobox-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function MyComboboxControl() {
const [ filteredOptions, setFilteredOptions ] = useState( options );
return (
<ComboboxControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label="Font Size"
value={ fontSize }
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/combobox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type { ComboboxControlOption, ComboboxControlProps } from './types';
import type { TokenInputProps } from '../form-token-field/types';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const noop = () => {};

Expand Down Expand Up @@ -92,6 +93,7 @@ const getIndexOfMatchingSuggestion = (
* const [ filteredOptions, setFilteredOptions ] = useState( options );
* return (
* <ComboboxControl
* __next40pxDefaultSize
* __nextHasNoMarginBottom
* label="Font Size"
* value={ fontSize }
Expand Down Expand Up @@ -313,6 +315,12 @@ function ComboboxControl( props: ComboboxControlProps ) {
}
}, [ matchingSuggestions, isExpanded ] );

maybeWarnDeprecated36pxSize( {
componentName: 'ComboboxControl',
__next40pxDefaultSize,
size: undefined,
} );

// Disable reason: There is no appropriate role which describes the
// input container intended accessible usability.
// TODO: Refactor click detection to use blur to stop propagation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const Template: StoryFn< typeof ComboboxControl > = ( {
};
export const Default = Template.bind( {} );
Default.args = {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
allowReset: false,
label: 'Select a country',
Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/combobox-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ const getOptionSearchString = ( option: ComboboxControlOption ) =>
option.label.substring( 0, 11 );

const ComboboxControl = ( props: ComboboxControlProps ) => {
return <_ComboboxControl { ...props } __nextHasNoMarginBottom />;
return (
<_ComboboxControl
{ ...props }
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
);
};

const ControlledComboboxControl = ( {
Expand Down

0 comments on commit fbc8c9f

Please sign in to comment.