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
Cant use enum's in template #16386
Comments
Is there any fix to this? Most of my stories are broken in multiple projects. Basically Storybook is unusable at the moment. My team and customers cant review the components in Storybook. In the console it shows a warning:
|
@MickL Do you a have a reproduction repo you can share? If not, can you create one? See how to create a repro. We prioritize issues with reproductions over those without. Thank you! 🙏 |
Here is a reproduction repro: https://github.com/MickL/storybook-enum-issue As you can see in the story the enum is not working. If you start the Angular app normally with Just to mention I already invested SO much time with problems I had with Storybook and creating Github issues. It hasnt been a good experience to use Storybook with Angular over the last year. |
Will this ever be fixed or at least reviewed? Storybook is currently unusable in multiple huge projects we work on. |
@storybookjs/angular This one is pretty strange. Is there something non-standard about how we compile templates? I can reproduce with the repo @MickL has provided above |
This seems to be an issue with Storybook and Compodoc. Looking at Compodoc output the "defaultValue" is "Animals", which is not correct. I don't know what Compodoc should be expected to put for the default value, because I don't know how enums are supposed to be serialized/deserialized, but if Compodoc would have specified the "type" as "enum" then it would at least be more clear that the "defaultValue" shouldn't be a string. https://github.com/MickL/storybook-enum-issue/blob/main/documentation.json#L38 The bigger issue is that Storybook should have never touched that property. The property is not an input/output, so I see no reason for there to even be a control in the ArgsTable, unless there is a control manually configured in the "argTypes" for that story. This should not be necessary, but a workaround is to specify the "props" manually, like the following: const Template: Story<AnimalComponentComponent> = (
args: AnimalComponentComponent
) => ({
// props: args,
props: {
animal: args.animal,
},
}); |
I've bumped into this issue myself. The workaround I used was to declare enum as a getter instead of a field like this: @Component({...})
export class MyComponent {
get animals() {
return Animals;
}
} It's a simple workaround, but I dislike that it requires modifying the component code to make a component work with both storybook and app. |
Coming back to Storybook 1 year later, still not fixed, still most of our components are broken. Sadly our team decided to use Storybook for a project. |
Same issue here. When running Storybook all the enums stop working, when you rename the enum and rebuild it works... |
I agree, it's really not great having the enums not working. |
This needs fixing not only enums are not working but functions, formControls, class variables have the same issue!. |
Same for me. I notice that it's work's fine until documentation.json was regenerated, from that controls of enum not working anymore... Can't use storybook in my angular project without this... |
@FrancoisTurpinLeocare Which version of Storybook are you using? |
@valentinpalkovic I link a screenshot of my package.json. |
Thank you @FrancoisTurpinLeocare. In Storybook 7.0 (currently in beta) we did a lot of improvements also related to Angular. Please check it out and let me know, if the issue still exists for you. Please read the migration guide and upgrade today if you want
|
Removing this from the 7.0 burndown until we have a 7.0 reproduction |
Closing the issue because I cannot reproduce it in Storybook 7.0.x |
Describe the bug
Within an Angular component, declaring a class-/template-variable that is an enum, does not work in Storybook templates.
To Reproduce
I noticed this already in earlier versions of Storybook. Weirdly if I rename the enum while Storybook is running, it suddenly works. But if I stop the process or make build, its not working again.
System
The text was updated successfully, but these errors were encountered: