Skip to content

Commit

Permalink
SelectControl: Add onChange, onBlur and onFocus to storybook actions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Petter Walbø Johnsgård authored Nov 1, 2022
1 parent 5ff5acd commit 62987d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- `CustomGradientBar`: Refactor away from Lodash ([#45367](https://github.com/WordPress/gutenberg/pull/45367/)).
- `TextControl`: Set Storybook control types on `help`, `label` and `type` ([#45405](https://github.com/WordPress/gutenberg/pull/45405)).
- `Autocomplete`: use Popover's new `placement` prop instead of legacy `position` prop ([#44396](https://github.com/WordPress/gutenberg/pull/44396/)).
- `SelectControl`: Add `onChange`, `onBlur` and `onFocus` to storybook actions ([#45432](https://github.com/WordPress/gutenberg/pull/45432/)).
- `FontSizePicker`: Add more comprehensive tests ([#45298](https://github.com/WordPress/gutenberg/pull/45298)).

## 21.3.0 (2022-10-19)
Expand Down
13 changes: 9 additions & 4 deletions packages/components/src/select-control/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,28 @@ const meta: ComponentMeta< typeof SelectControl > = {
value: { control: { type: null } },
},
parameters: {
actions: { argTypesRegex: '^on.*' },
controls: { expanded: true },
docs: { source: { state: 'open' } },
},
};
export default meta;

const SelectControlWithState: ComponentStory< typeof SelectControl > = (
args
) => {
const SelectControlWithState: ComponentStory< typeof SelectControl > = ( {
onChange,
...args
} ) => {
const [ selection, setSelection ] =
useState< ComponentProps< typeof SelectControl >[ 'value' ] >();

return (
<SelectControl
{ ...args }
value={ selection }
onChange={ setSelection }
onChange={ ( value ) => {
setSelection( value );
onChange?.( value );
} }
/>
);
};
Expand Down

0 comments on commit 62987d7

Please sign in to comment.