-
-
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
Addon-controls: Improve select arg serialization #13888
Comments
Is this related? #12613 |
Yes, seems like this would also fix #12613 |
@ghengeveld chatted with @tmeasday about this today. his suggestion (which I think makes sense) is to make this a feature of args. So
Then it would be up to the StoryStore to transform the serializable values into the complex values before the story is rendered. WDYT? |
Shiver me timbers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-beta.8 containing PR #14100 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Going to reopen this because we changed our minds. The new proposal is: argTypes.children = {
options: ['a', 'b', 'c'], // Must be an array
mapping: { // Must be an object
a: <A />,
b: <B />,
},
control: {
type: 'select', // inferred from options existing
labels: { // Inferred from `options` if set -- must be an object
a: 'A is a good choice',
b: 'João',
}
}
} |
@acerbastimur That looks like you want a control on a nested property. Unfortunately that's not possible. However you can use the newly introduced JSON editor for objects such as Feel free to open a feature request for controls on nested properties. Your example it a legit use case. |
Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-beta.12 containing PR #14169 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Currently, all keys and values must be JSON serializable (telejson-serializable, actually), which is a serious restriction when components can take arbitrary blob values / complex functions as their inputs.
If we modify the
select
arg serialization, we can make use of the existing API to support non-serializable objects.Consider the following example:
Currently this will fail because we try to serialize
<Foo/>
,<Bar/>
, and<Baz/>
, which are non-serializable. However, if we updated the behavior to serializeOne
,Two
, andThree
, and then did a lookup in the options map before the arg values were passed into the story rendering function, then the user could use any value.This would be a non-breaking change because the serialization behavior is currently an implementation detail.
Fixing this will also mitigate the security restrictions introduced in URL handling: #13803
┆Issue is synchronized with this Asana task by Unito
The text was updated successfully, but these errors were encountered: