-
-
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
In argTypes, options array prevents args being passed to canvas in iframe #17413
Comments
We are having a similar issue where our different button color variants change back to the default colors but only when opened in a new canvas tab. So in our case, a secondary grey button appears as a primary teal button. |
I'm not sure if this is a bug or a documentation issue or both. The issue is that you're using the deprecated If you update your example to this, it should work as expected:
This is documented here but does not document the implications about the canvas iframe, whose behavior seems inconsistent with the |
I don't think setting |
This workaround seems to work sporadically. And on when implementing optional props, like adding an icon to a button, it reverted back to default styling. We also tried removing the customised argTypes and it still made no difference. |
@shilman Thanks so much for your response. Unfortunately the workaround you posted has not fixed the issue for me: export default {
title: "Example/Button",
component: Button,
args: {
label: "string",
},
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
label: {
options: ["string", "jsx"],
mapping: {
string: "Option 1",
jsx: <em>Option 1</em>,
},
control: "radio",
},
backgroundColor: { control: "color" },
},
} Do you have any other suggestions? iframe exhibiting behaviour: https://6214928c283a59003ac59209-qjmbgslptk.chromatic.com/iframe.html?args=&id=example-button--primary&viewMode=story Storybook: https://6214928c283a59003ac59209-qjmbgslptk.chromatic.com |
I am experiencing this same issue after upgrading from Storybook 6.3.12 to 6.4.19. I think I have narrowed down that this is due to the 'options' array, when defining argTypes in a story file as well. If I remove the "options" array from a control's definition (radio, select, or other type that uses "options"), then the data for that field is passed correctly into the iframe. I am not using the Here's my environment information, if that is helpful: |
I'm experiencing the same issue: #17517 |
I am also experiencing this issue, I have no defaultValue anywhere in my project. My I do have an With the options array, I do see the URL updating as I change the options, but I note that refreshing causes Storybook to complain about omitting potentially unsafe URL tags, even though it's just the string key. Another thing I realized is that the official doc example uses both options and mapping here |
Experiencing this issue as well, with or without defaultValue |
@SiAdcock This took ages but I upgraded your repro to Storybook 7.0.x and the problem appears to be fixed there. Closing this one -- please feel free to reopen if you believe it's still a problem in the latest release! |
Describe the bug
I get a lot of use out of opening a canvas in a new tab. However, I find that args are not passed to the component in the new tab when using the
options
array as part of mapping to complex arg values.Removing the
options
array and thecontrol
property fixes the issue, however the user is then expected to manually enter the mapping key, which is not easy to find.e.g.
In canvas view within Storybook UI:
Opening canvas in new tab:
To Reproduce
To see the component within a tab with no args:
https://61fc54fb66066e003a36e1a1-omnrupgxxj.chromatic.com/iframe.html?args=&id=example-button--primary&viewMode=story
To navigate via the Storybook UI:
https://61fc54fb66066e003a36e1a1-omnrupgxxj.chromatic.com/?path=/story/example-button--primary
I have created a minimal repro with instructions at this repo:
https://github.com/SiAdcock/test-sb-options
System
The text was updated successfully, but these errors were encountered: