Storybook: Addons / Knobs - When type is Number using the number knob, throws an error on delete and field is null

Created on 15 Jan 2020  路  7Comments  路  Source: storybookjs/storybook

Describe the bug
You have a knob, the prop type is Number and the default is number('something', 0). If the user deletes the 0 (or all digits in the field), an error is thrown in the console because the value cannot be null

vendors~main.5317d89c4b17337a8714.bundle.js:103113 Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.

To Reproduce
Steps to reproduce the behavior:

  1. Set a prop using a knob in a story
      hello: {
        type: Number,
        default: number('hello', 0),
      },
  1. Use it in the template
  2. Run the Storybook
  3. Navigate to the story, delete the value in that knob field
  4. See error in console

Expected behavior
Either accept null (since it's a valid value for Number) or on delete set back the default value or 0. I dunno whatever makes sense to you.

System:

Environment Info:

  System:
    OS: macOS 10.15.2
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 10.5.0 - ~/.nvm/versions/node/v10.5.0/bin/node
    npm: 6.1.0 - ~/.nvm/versions/node/v10.5.0/bin/npm
  Browsers:
    Chrome: 79.0.3945.117
    Firefox: 71.0
    Safari: 13.0.4
  npmPackages:
    @storybook/addon-a11y: ^5.0.3 => 5.1.9
    @storybook/addon-cssresources: ^5.0.11 => 5.1.9
    @storybook/addon-knobs: ^5.1.8 => 5.1.9
    @storybook/addon-notes: ^5.1.8 => 5.1.9
    @storybook/addon-viewport: ^5.1.8 => 5.1.9
    @storybook/theming: ^5.1.8 => 5.1.9
    @storybook/vue: ^5.2.8 => 5.2.8

Extra
Right now to bypass that limitation, I use a String that I parse as a Number in the template..

knobs bug inactive

Most helpful comment

still an issue

All 7 comments

Let me know if you guys if you need more info

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!

I didn't have the time to investigate more, but this is still a problem in latest version.

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!

still an issue

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

Related issues

ChucKN0risK picture ChucKN0risK  路  74Comments

dmmarmol picture dmmarmol  路  57Comments

EdenTurgeman picture EdenTurgeman  路  81Comments

joeruello picture joeruello  路  79Comments

p3k picture p3k  路  61Comments