Addons / Knobs - When type is Number using the number knob, throws an error on delete and field is null
See original GitHub issueDescribe 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:
- Set a prop using a knob in a story
hello: {
type: Number,
default: number('hello', 0),
},
- Use it in the template
- Run the Storybook
- Navigate to the story, delete the value in that knob field
- 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:
- Created 4 years ago
- Reactions:1
- Comments:7
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
still an issue
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!