Storybook: Problem of options-knob with display='multi-select'

Created on 12 Aug 2020  路  2Comments  路  Source: storybookjs/storybook

Describe the bug

When using options knob valueObjects to be array of Object, on choose of mutil options, the select box would fallback to empty

To Reproduce
Steps to reproduce the behavior:

`
import { optionsKnob } from '@storybook/addon-knobs';

const label = 'Fruits';
const valuesObj = {
Kiwi: { label: 'kiwi' },
Guava: { label: 'Guava' },
Watermelon: { label: 'Watermelon' },
};
const defaultValue = [{ label: 'kiwi' }];
const optionsObj = {
display: 'multi-select',
};
const groupId = 'GROUP-ID1';

const value = optionsKnob(label, valuesObj, defaultValue, optionsObj, groupId);
`

Expected behavior

I think problems goes here:
`
if (isMulti) {
defaultValue = options.filter(function (i) {
return knob.value.includes(i.value);
});

  handleChange = function handleChange(values) {
    return onChange(values.map(function (item) {
      return item.value;
    }));
  };
}

return _react["default"].createElement(OptionsSelect, {
  value: defaultValue,
  options: options,
  isMulti: isMulti,
  onChange: handleChange
});

`

The knob panel receive message back(which is deserialized) , and the
options.filter(function (i) {
return knob.value.includes(i.value);
});

would result in [] because the value are type of object

knobs question / support

All 2 comments

FYI, we鈥檝e released addon-controls in Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replace addon-knobs long term.

Please upgrade and try them out today!

That's Great! I will try 6.0 and addon-control

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZigGreen picture ZigGreen  路  3Comments

zvictor picture zvictor  路  3Comments

shilman picture shilman  路  3Comments

tlrobinson picture tlrobinson  路  3Comments

xogeny picture xogeny  路  3Comments