question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

4reactions
poblouincommented, Mar 3, 2020

still an issue

0reactions
stale[bot]commented, Apr 25, 2020

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Knobs Addon | Storybook: Frontend workshop for UI ...
Storybook Addon Knobs allow you to edit props dynamically using the Storybook UI. You can also use Knobs as a dynamic variable inside...
Read more >
Error handling - Apollo GraphQL Docs
This GraphQLError neatly formats the error and contains useful fields, such as the path where the error occurred. In you want to remove...
Read more >
Control flow and error handling - JavaScript - MDN Web Docs
Exception handling statements. You can throw exceptions using the throw statement and handle them using the try... catch statements.
Read more >
Changelog - Cypress Documentation
Cypress now throws an error if any Cypress commands are invoked from inside a .should() callback. This previously resulted in unusual and undefined...
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
It's recommended to use the predefined library constant for code clarity and better precision. NP: Method with Boolean return type returns explicit null...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found