-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Angular: Fix multiple calls of Input setter #17633
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 185b5e7. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
ff94ff2
to
08ab5d0
Compare
@@ -104,13 +112,15 @@ describe('StorybookModule', () => { | |||
it('should change inputs if storyProps$ Subject emit', async () => { | |||
const initialProps = { | |||
input: 'input', | |||
inputBindingPropertyName: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are wondering why I am modifying the test here :
If a new entry was added to the list of props between the initialisation of the story and a lazy (emit on storyProps$) change of the input values
like : Initial { InputA : 'A' }
new change : { InputA : 'A', InputB: 'B' }
The new Input was not added in the template like the first one <foo [InputA]="InputA" ></foo>
because not new rendering a made only rxjs event with new props.
Before it worked because the property was added as a non Input Output property, overwriting the component property directly.
which was not good because angular could not detect the changes with the NgOnChanges for example
But anyway all this should not happen because a higher level mechanism detect if lazy rendering can be done. By comparing templates to see if there is a diff.
so in the test here all Input Output must be existing at init step
08ab5d0
to
61e22f6
Compare
61e22f6
to
185b5e7
Compare
Hey @ThibaudAV could you give me a small set of steps to reproduce this in the monorepo? I'd be happy to do some QA! |
@yannbf Of course with pleasure : Without this change
So with this change now setter are no more called after I will add some specific use case into angular-cli to avoid future regression on this. if you agree ? |
👋 @yannbf any news on this ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ThibaudAV sorry it took me time to test this. Works closer to the angular app now so it's great 👌
Thanks a lot for the contribution!
Angular: Fix multiple calls of Input setter
Maybe : #15610
Potential link : #11613
What I did
Investigate why in some case we have multiple call with some Input setter.
Reasons :
When a Story does not define a template and lets storybook build it from the component
or
When Meta define component and this component is used in the story template
the props are set twice. One for the wrapper component. And also directly set into the target component.
Now only none Input / Output are directly send to the target component
The values for the normal Input will be sent by the angular property biding
How to test
If your answer is yes to any of these, please make sure to include it in your PR.