Open
Description
Describe the bug
When creating a story for a component that includes host directives, storybook doesn't provide the inputs to the directive. Additionally, the declared interface of the component class is used to enforce type safety in the story so the host directive inputs are not seen as valid properties.
Reproduction link
https://stackblitz.com/edit/github-6ta5gcj5?file=src%2Fstories%2Fdemo.component.ts
@Directive({
selector: '[plTest]',
standalone: true,
})
export class TestDirective {
someInput = input();
constructor() {
console.log('created directive');
effect(() => {
console.log('someInput', this.someInput()); // THIS SHOULD LOG THE VALUE PROVIDED FROM THE STORY. IT DOESN'T.
});
}
}
@Component({
selector: 'pl-demo',
template: `
<div>This is a demo
</div>
`,
hostDirectives: [{ directive: TestDirective, inputs: ['someInput'] }],
})
export class DemoComponent {
// HACK: suggested workaround is to re-declare the mapped input here to make SB happy.
// someInput = input();
}
Reproduction steps
- Go to the above link. Open the console. Note there is no valid output logged from the default value provided for
someValue
in the story
System
Additional context
Same code works just fine in an angular application