You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When we have a component with a prop, not declared as an input, it is reinitialized to its default value even if the ngOnInit set a value.
In the example below I assign an array to the prop. I should have the "Hello" text displayed, but I have an empty view for the component.
To Reproduce
Create a simple component with a prop assigned in the ngOnInit :
import{Component,OnInit}from"@angular/core";
@Component({selector: "test",template: `<p *ngFor="let entry of prop">{{entry.value}}</p>`})exportclassTestComponentimplementsOnInit{privateprop=[];publicngOnInit(){this.prop=[{value: "Hello"}];}}
Expected behavior
I should have in my canvas a p tag with "Hello" as innerText.
There are several issues more or less related to the same problem (ex: #11613, #12946)
If we change this it causes braking changes.
Which IMHO would be good things. And would "force" users to interact only with Angular Input/Output.
And we could add something like this overrideComponentProps which would overload component props as before (even if it's bad to do it)
Not reproducible in Storybook 7 / Angular 15 anymore. Therefore, I am closing this. Please reopen the issue if you still encounter it. Please provide a Stackblitz reproduction in this case (https://storybook.new)
Describe the bug
When we have a component with a prop, not declared as an input, it is reinitialized to its default value even if the ngOnInit set a value.
In the example below I assign an array to the prop. I should have the "Hello" text displayed, but I have an empty view for the component.
To Reproduce
Create a simple component with a prop assigned in the ngOnInit :
Expected behavior
I should have in my canvas a
p
tag with "Hello" as innerText.System
System:
OS: Linux 5.3 Ubuntu 19.10 (Eoan Ermine)
CPU: (2) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
Binaries:
Node: 12.18.4 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/bin/yarn
npm: 6.14.6 - /usr/local/bin/npm
Browsers:
Chrome: 84.0.4147.125
Firefox: 78.0.2
npmPackages:
@storybook/addon-actions: ^6.2.0-alpha.14 => 6.2.0-alpha.14
@storybook/addon-essentials: ^6.2.0-alpha.14 => 6.2.0-alpha.14
@storybook/addon-links: ^6.2.0-alpha.14 => 6.2.0-alpha.14
@storybook/addons: ^6.2.0-alpha.14 => 6.2.0-alpha.14
@storybook/angular: ^6.2.0-alpha.14 => 6.2.0-alpha.14
@storybook/theming: ^6.2.0-alpha.14 => 6.2.0-alpha.14
Can also be reproduced in alpha.15.
Additional context
This issue is probably linked to this PR : #13507
The prop is reset by the
ngAfterViewInit
call ofStorybookWrapperComponent
.On the following lines :
initialProps
contains an empty array forprop
in my example.ping @ThibaudAV
The text was updated successfully, but these errors were encountered: