Skip to content

Commit

Permalink
Addon-knobs: Fix null knob values in select (#9416)
Browse files Browse the repository at this point in the history
Addon-knobs: Fix null knob values in select
  • Loading branch information
shilman committed Jan 13, 2020
1 parent 39201f2 commit 42fa30b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/knobs/src/components/types/Select.tsx
Expand Up @@ -32,7 +32,7 @@ const SelectType: FunctionComponent<SelectTypeProps> & {
const { options } = knob;

const callbackReduceArrayOptions = (acc: any, option: any, i: number) => {
if (typeof option !== 'object') return { ...acc, [option]: option };
if (typeof option !== 'object' || option === null) return { ...acc, [option]: option };
const label = option.label || option.key || i;
return { ...acc, [label]: option };
};
Expand Down
Expand Up @@ -45,6 +45,12 @@ export default {
decorators: [withKnobs],
};

export const selectKnob = () => {
const value = select('value', [1, 2, 3, undefined, null], 1);

return <div>{JSON.stringify({ value: String(value) }, null, 2)}</div>;
};

export const TweaksStaticValues = () => {
const name = text('Name', 'Storyteller');
const age = number('Age', 70, { range: true, min: 0, max: 90, step: 5 });
Expand Down

0 comments on commit 42fa30b

Please sign in to comment.