Skip to content

[Bug]: Storybook for Angular doesn't map host directive inputs #30537

Open
@snortblt

Description

@snortblt

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

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions