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
Numeric literals don't work properly with defaultValue #15446
Comments
This looks like a bug in the new default handling code and/or the URL serialization
What's happening:
|
Something to do with enum handling:
|
Ok the problem is this line @ghengeveld : storybook/lib/client-api/src/story_store.ts Line 283 in bd90a23
The proximate cause is that the arg type is being detected as a set of strings as options. I think the idea here is off though. We can't rely on arg types being right (this case being a great example). We should not be overriding something explicit ( Also I find it kind of weird that this code changes args without calling |
Per @tmeasday's suggestion on another issue I was having that may be related, I did some debugging around that line mentioned. I posted this in Discord but I'll add it here too in case it's helpful: On first load, before calling When dealing with a numeric literal as mentioned in this issue, it exists in the first log, but is entirely removed from the second. Other |
Describe the bug
Numeric literals don't work with a
number
defaultValue
on first load.I believe this is related to the change to deprecate
argTypes.defaultValue
, but I believe the code in the repro should work as-is. It does work when passing astring
as adefaultValue
, even if the type is a numeric literal.To Reproduce
https://github.com/ajosedev/sb-default-value-numeric-repro
System
Additional context
I'm unsure if this is a problem with Storybook as it only started happening when upgrading from
6.1.20
, or if it's in the underlying docgen code.The behaviour only seems to happen on a refresh of the page. Meaning that if you navigate to the page from another story, the
defaultValue
will work even if it's anumber
.Also of note, you can see the console log for
argTypes.sizeAsNumber.options
is an array of strings.Let me know if I've set up the repro correctly, haven't done many of these 🙏
The text was updated successfully, but these errors were encountered: