-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
[Bug]: Error when trying to create a story for a not standalone component that extends a standalone component #26056
Comments
Can you check out the latest Storybook 8 beta? AFAIK it has some Angular improvements. |
@valentinpalkovic thanks for the suggestion! But unfortunately it didn't help, just tried it :( |
I managed to work around this issue by creating a dummy standalone component inside the story file. And then using that component in the story. @Component({
standalone: true,
imports: [RealComponentWhichExtendsOther],
template: `
<app-real></app-real>
`,
})
class DummyComponent {}
export default {
component: DummyComponent,
title: 'RealComponent',
}; |
I think I see what is happening and it does appear to be a bug. I can't remember exactly how Angular handles the class decorator, when extending a class. If I am remembering correctly, though, it doesn't look at anything, other than the decorator that is added to the class directly. I would need to confirm, before I can say that is actually correct. Assuming my understanding is correct, then Storybook's usage of |
Ah, I think your right. At least in my case the parent component is |
We have found a solution. You are welcome to try it and see if it works for you. It's not a sustainable solution, but it would be interesting to know if it works everywhere. My testing capabilities were very limited... Manually apply the changes from the pull request https://github.com/storybookjs/storybook/pull/27353/files#diff-4ff611f840cb60ea92c0c47c5e7fced91a9f8d4a57fea7c9b7d3e7b5b97c46ca in Replace
With
Hopefully, this will be fixed in one of the upcoming releases. :) |
Describe the bug
I have two components - the Parent component is standalone, the Child one - not standalone. Child extends Parent (
class ChildComponent extends ParentComponent
) and when I'm trying to create a story for the child I get an errorUnexpected directive 'ChildComponent' imported by the module 'StorybookComponentModule'. Please add an @NgModule annotation
. If I remove extending from the Child or if I addstandalone: true
to it the error disappearsTo Reproduce
https://stackblitz.com/edit/github-qnhd3h
There's a story for Child component - you can navigate to it using storybook interface
System
Additional context
No response
The text was updated successfully, but these errors were encountered: