Skip to content

Commit

Permalink
SelectControl: mark the children prop as optional (#37872)
Browse files Browse the repository at this point in the history
* `SelectControl`: mark the `children` prop as optional

* Update prop documentation

* Rename Storybook example

* Changelog
  • Loading branch information
ciampo authored and noisysocks committed Jan 17, 2022
1 parent d983416 commit 7bbaf28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug Fix

- Prevent keyDown events from propagating up in `CustomSelectControl` ([#30557](https://github.com/WordPress/gutenberg/pull/30557))
- Mark `children` prop as optional in `SelectControl` ([#37872](https://github.com/WordPress/gutenberg/pull/37872))

## 19.2.0 (2022-01-04)

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/select-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ An array of objects containing the following properties:

#### children

An alternative to the `options` prop.
An alternative to the `options` prop.
Use the `children` prop to have more control on the style of the items being rendered, like `optgroup`s or `options` and possibly avoid re-rendering due to the reference update on the `options` prop.
- Type: `Element`
- Type: `ReactNode`
- Required: No

#### onChange
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { isEmpty, noop } from 'lodash';
import classNames from 'classnames';
// eslint-disable-next-line no-restricted-imports
import type { ChangeEvent, FocusEvent, Ref } from 'react';
import type { ChangeEvent, FocusEvent, ReactNode, Ref } from 'react';

/**
* WordPress dependencies
Expand All @@ -31,7 +31,7 @@ function useUniqueId( idProp?: string ) {
}

export interface SelectControlProps
extends Omit< InputBaseProps, 'isFocused' > {
extends Omit< InputBaseProps, 'children' | 'isFocused' > {
help?: string;
hideLabelFromVision?: boolean;
multiple?: boolean;
Expand All @@ -50,6 +50,7 @@ export interface SelectControlProps
size?: Size;
value?: string | string[];
labelPosition?: LabelPosition;
children?: ReactNode;
}

function SelectControl(
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/select-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const _default = () => {
return <SelectControlWithState { ...props } />;
};

export const withNativeChildren = () => {
export const withCustomChildren = () => {
return (
<SelectControlWithState label="Value">
<option value="option-1">Option 1</option>
Expand Down

0 comments on commit 7bbaf28

Please sign in to comment.