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
[Angular] Addon-controls: inference issues with enum props #12531
Comments
Thanks @shilman, I've obviously read it before posting this issue 😄 If my type is not an enum but an union type, it works : export class AvatarComponent {
@Input() size?: 'small' | 'medium' | 'large'; // Auto-generated in select input
} export class AvatarComponent {
@Input() size?: AvatarSize; // Auto-generated in text input
} Thanks for your answer and have a good day ! |
We're using |
First of all, I really appreciate the efforts of the Storybook team! The Controls addon is a fantastic addition! I came across this issue also so I did some digging. This is the relevant function as far as I can tell. storybook/addons/docs/src/frameworks/angular/compodoc.ts Lines 115 to 125 in cdd97a8
The code below doesn't generate a select input control because the export class AvatarComponent {
@Input() size?: AvatarSize; // Auto-generated in text input
}
enum AvatarSize {
SMALL = 'SMALL',
MEDIUM = 'MEDIUM',
LARGE = 'LARGE',
} The same problem exists when using a type alias like this: export class AvatarComponent {
@Input() size?: AvatarSize;
}
type AvatarSize = 'small' | 'medium' | 'large' While {
// ...
"miscellaneous": {
// ...
"enumerations": [
// ...
{
"name": "AvatarSize",
"childs": [
{
"name": "SMALL"
},
{
"name": "MEDIUM"
},
{
"name": "LARGE"
}
],
"ctype": "miscellaneous",
"subtype": "enum",
"description": "",
"file": "src/avatar/avatar.component.ts"
},
]
}
} |
@lachieh thanks for the research on this. should be pretty easy to add this to |
I would be interested! Point me in the right direction and I'll get started. |
@shilman I notice there's a |
Sorry, missed your previous comment. Relevant code is here: Please be sure to add a test case to |
This isn't just an angular issue, I'm seeing the same on React. And the OP talked about vue. I assume it's for the exact same reason there. |
One thing to note for my PR is that even though I have been able extract the values from an enum type, the only version of enums that work are String Enums. When I got the value to assign to the dropdown control, even though the enum had a name, the control input displays the number value (0, 1, 2, etc). It's possible that a future iteration of docs and/or controls needs to support enums that have a value and a label, instead of just a list of values. |
Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-alpha.0 containing PR #12665 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
I am not sure that my issue is related to this but I've got this type of behaviour in
"@storybook/vue": "^6.0.21"
:Default.args
Originally posted by @justice47 in #12007 (comment)
I'm experiencing the same problem with Angular.
Storybook version :
6.0.21
Angular version :
8.2.14
Example given with an avatar component :
The
size
control is displayed as a textfield and not a select.The text was updated successfully, but these errors were encountered: