-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Controls: Rework default value handling #14579
Comments
a thought that comes to me while reading : 😁 |
Can anyone think of a workaround that's better than applying a decorator like so: (Story, { args }) => {
const { argName: ignoreArgName, ...restArgs } = args;
return <Story args={restArgs} />;
}, This approach has two major limitations:
|
@kylegach @ThibaudAV we're introducing a new UPDATE: added |
@shilman Okay
We can't have documentation on a class without assigning a value for each property in args. I think that with the rework it could be nice to differentiate agrTypes for docs only from those with an interaction adding a value in args 🤷♂️ UPDATE ⬆️ I need to test 😄 |
@ThibaudAV great point 🤦 i'll sleep on it and see if i can come up with something better |
Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.0-alpha.31 containing PR #14901 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Not sure if I'm missing something here, but I have issues with initializing all props to I think there should be a difference between setting a prop to |
@mboettcher it's being discussed here FYI #15378 |
Instead of initializing an optional control value to its default value, initialize it to
undefined
Rationale
Default value handling is currently problematic in Storybook's Arg handling.
We statically analyze the code to determine the default value. This is impossible to do statically in all cases, and on top of that there are various inconsistencies between how different libraries handle the output (e.g. string literal vs expression).
This leads to issues such as #14387 #14370 #13919 and many more.
However, since the default value gets set automatically when NO value is passes to the component, passing
undefined
is a much better option. It sidesteps all the existing issues and the component will use the runtime default value, which will be correct.What's needed
A few different things are needed to make this happen:
undefined
and resetaddon-actions
needs to move from ArgTypeEnhancer to ArgEnhancerargs
, notargType.defaultValue
Open question:
Do we want=> YESargTypes.x.defaultValue
to setargs.x
automatically?The text was updated successfully, but these errors were encountered: