-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InputControl: remove default value argument from Storybook #40410
InputControl: remove default value argument from Storybook #40410
Conversation
Ah interesting! The reason I added a I think the underlying tension is between wanting to showcase it simply as an uncontrolled component vs. showcasing it as a controlled component, the latter of which is how almost every consumer would use it. I can think of two ways to somewhat reconcile this tension:
What do you think? |
409b688
to
4cc6042
Compare
I also prefer option 1, but I also pushed a commit that introduces the "controlled" version as a separate story — maybe this could be the best compromise overall, what do you think? I'm also happy to revert my changes and only include what we called "option 1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer option 1, but I also pushed a commit that introduces the "controlled" version as a separate story — maybe this could be the best compromise overall, what do you think?
At the moment I don't have a strong opinion either way, but I'm curious what you think the purpose of the controlled story is. My worry is that it could be confusing to be there in the Docs view with no explanation, and with an "incomplete" autogenerated code snippet.
I noticed one benefit of having it, which is to have the use case be type checked. Like I noticed that this code sample in the JSDoc throws a type error for the onChange
:
gutenberg/packages/components/src/input-control/index.tsx
Lines 100 to 107 in 4cc6042
* const [ value, setValue ] = useState( '' ); | |
* | |
* return ( | |
* <InputControl | |
* value={ value } | |
* onChange={ ( nextValue ) => setValue( nextValue ) } | |
* /> | |
* ); |
Though if it's just for type checking we could move it to a unit test.
You make a good point, let's not have a controlled story at least for now (it's always something that we can add later if we feel like we need it). I went ahead and removed the controlled story, and then fixed the JSDoc snippets by adding a fallback empty string value in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with that! 🚢
packages/components/CHANGELOG.md
Outdated
## 19.8.0 (2022-04-08) | ||
|
||
### Bug Fix | ||
|
||
- `InputControl`: allow user to input a value interactively in Storybook, by removing default value argument ([#40410](https://github.com/WordPress/gutenberg/pull/40410)). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed it's under the wrong version heading 🧹
What?
Fixes a bug in
InputControl
's Storybook example, where currently it's not possible to interact with the component and enter a custom valueWhy?
This is probably an unwanted side-effect introduced in #40119
How?
This PR removes
value: ''
from the list of default arguments for each Storybook example.Testing Instructions
Open Storybook, make sure that it's possible to enter a custom value in the
InputControl
component and that the value is persisted after the input loses focus.Make sure that any text manually set as the
value
via Storybook controls overrides every other text entered by the user.Screenshots or screencast
Before:
input-control-value-before.mp4
After:
input-control-value-after.mp4