Storybook: Knobs don't update when the dropdown option are generated dynamically.

Created on 3 Nov 2018  路  4Comments  路  Source: storybookjs/storybook

Describe the bug
I have two knobs, text input and select. The text input is for accepting a json object. The select dropdown will generate options dynamically according to the data input. However, the select doesn't update at all

To Reproduce
Steps to reproduce the behavior:

  1. Create two knowbs, "text" and "select"
  2. Enter a json object with many properties.
  3. Parse the json object from "text input" and generate options per attribute
  4. Pass the new options into "select" input

Expected behavior
The dropdown should update with new options

Screenshots
image

Code snippets

[examples.BASIC_EXAMPLE]: function Story1() {
  const groupDataInput = 'Data input';
  const customizations = 'customizations';
  const newData = object('Data', complexMock, groupDataInput);
  const options = extractDataOptions(newData[0]);
  const sizeControl = select(
    'Size control', options, customizations
  );
  return (
    <MyComponent
      data={newData}
      sizeControl={sizeControl}
    />
  );
},

System:

  • OS: MacOS
  • Device: Macbook Pro 2018
  • Browser: Chrome
  • Framework: React
  • Version: 4.0.0
knobs inactive question / support

Most helpful comment

@ardouglass hi! I stumbled upon this issue too, as I'm trying to update one knob based on another.

Something that seems like it could hep in my case, and possibly yours and @javidhsueh's (perhaps) is a combination of this: https://github.com/storybooks/storybook/pull/3909 and using forceReRender.

Currently it looks like the select() knob on its own doesn't allow too much in the way of dynamic updates.

All 4 comments

I came across a mostly similar issue trying to load fake data for a select with the fetch API. I believe a solution to this issue would also solve my problem.

@ardouglass hi! I stumbled upon this issue too, as I'm trying to update one knob based on another.

Something that seems like it could hep in my case, and possibly yours and @javidhsueh's (perhaps) is a combination of this: https://github.com/storybooks/storybook/pull/3909 and using forceReRender.

Currently it looks like the select() knob on its own doesn't allow too much in the way of dynamic updates.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings