Skip to content
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]: Storybook issue with Angular Signals input #28412

Open
tobiaskau opened this issue Jul 1, 2024 · 8 comments
Open

[Bug]: Storybook issue with Angular Signals input #28412

tobiaskau opened this issue Jul 1, 2024 · 8 comments

Comments

@tobiaskau
Copy link

tobiaskau commented Jul 1, 2024

Describe the bug

Storybook does not properly support Angular Signal inputs. When creating a story with a component that uses the new Signal input as an input property, in the control tab of the story the type is not displayed properly (instead, only "Set string" input field is shown.)

In this screenshot you can see the difference how Storybook properly handles an @ Input() property but is unable to properly show the type of a Signal input (e.g. `testSignalsInput = input<'a' | 'b' | 'c' | undefined>(undefined);). In this scenario, both controls should actually be displayed in the same way (providing radio buttons with 'a', 'b' and 'c').
image

The test component in this scenario looks like this:
`import { Component, Input, input } from '@angular/core';

@component({
selector: 'app-test',
standalone: true,
imports: [],
template: <p> test works! </p>,
styles: ``,
})
export class TestComponent {
testSignalsInput = input<'a' | 'b' | 'c' | undefined>(undefined);

@input()
testInput?: 'a' | 'b' | 'c' = undefined;
}
`

Overall, this seems to be an issue with the compodoc dependency. In this PR (#26413) the issue was already mentioned. This is the related compodoc conversation. *Not sure if this is purely a compodoc issue or also related to Storybook, but it's worth mentioning that Storybook is currently almost unusable with apps using Angular Signals (which is the new Angular standard for inputs).

Reproduction link

https://stackblitz.com/edit/github-fbjw2b?file=src%2Fapp%2Ftest%2Ftest.component.ts

Reproduction steps

  1. Go to above link
  2. After Storybook is built, go to the /Test/Signals Test story.
  3. Go to the Controls tab
  4. Check the testInput input property - there are 3 radio buttons with values 'a', 'b' and 'c' (as intended)
  5. Check the testSignalsInput input property - you can only set a string here as an input, although the 3 predefined values should be shown

This is the issue - when using Angular Signals, the user cannot select between predefined values anymore (like previously possible when using @ Input()), as shown in the Stackblitz example. The testInput and testSignalsInput properties should be shown to the user in the same way, but currently when using the new Angular input syntax (e.g. `testSignalsInput = input<'a' | 'b' | 'c' | undefined>(undefined);) only a string input will be shown in the Storybook control tab.

System

Storybook Environment Info:

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm <----- active
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @storybook/addon-docs: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-essentials: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-interactions: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-links: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-onboarding: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/angular: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/blocks: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/test: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    storybook: ^8.2.0-alpha.10 => 8.2.0-alpha.10

Additional context

No response

@valentinpalkovic
Copy link
Contributor

I don’t think we at Storybook can do much about it. Let’s upvote compodoc/compodoc#1491 which hopefully fixes the issue in compodoc!

@tobiaskau
Copy link
Author

So the compodoc bug was merged (compodoc/compodoc#1491 (comment)), I think Storybook now needs a dependency update as soon as its released?

@valentinpalkovic
Copy link
Contributor

Sure! Hopefully compodoc is releasing soon-ish a new version.

@erikwski
Copy link

I'm waiting for the releasing of the new version too

@loxy
Copy link

loxy commented Oct 13, 2024

Can you explain why compodoc is required for this?

BTW, it seems to be there was no release since May 2024...

@bharathmuppa
Copy link

Also waiting for this to be Fixed. Any Updates on this?

@tobiaskau
Copy link
Author

Compodoc was released last month, are there any plans to update the dependency?

https://github.com/compodoc/compodoc/releases

@loxy
Copy link

loxy commented Nov 12, 2024

Compodoc was released last month, are there any plans to update the dependency?

https://github.com/compodoc/compodoc/releases

But it does not include the fix: compodoc/compodoc#1491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants