-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(forms): clean up connection between FormControl/FormGroup and corresponding directive instances #39235
Conversation
d559073
to
a199a8f
Compare
07def58
to
90fe4e5
Compare
a7669c9
to
68097e6
Compare
🥳 Kudos, Andrew! |
c0b1870
to
e5a2d31
Compare
Quick update: while testing this change I verified that the memory is released when |
…responding directive instances Prior to this commit, removing `FormControlDirective` and `FormGroupName` directive instances didn't clear the callbacks previously registered on FromControl/FormGroup class instances. As a result, these callbacks were executed even after `FormControlDirective` and `FormGroupName` directive instances were destroyed. That was also causing memory leaks since these callbacks also retained references to DOM elements. This commit updates the cleanup logic to take care of properly detaching FormControl/FormGroup/FormArray instances from the view by removing view-specific callback at destroy time. Closes angular#20007, angular#37431, angular#39590.
5152d0f
to
1e746f1
Compare
Global TAP run is successful, other checks are "green" too. The fix was also manually verified with a number of use-cases, so this PR is ready to go. Note to Caretaker: it'd be great to land this change as a separate sync CL so that it's easier to rollback if needed. |
@AndrewKushnir thanks a lot for all the work you've put in this, it'll be super helpful 🙏! |
PR angular#39235 introduced additional cleanup logic for form controls and directives. The cleanup logic relies on the presence of ControlValueAccessor instances on FormControlName and FormControl directives. In general these fields are present and there are also checks to make sure that the mentioned directive instances are created with CVAs. However some scenarios (primarily tests) may invoke the logic in a way that the directive instance would not be fully initialized, thus causing CVA to be absent. As a result, the cleanup logic fails while trying to call some methods on associated CVA instances. This commit updates the cleanup logic to take into account the situation when CVA is not present. Fixes angular#40521.
…#40526) PR #39235 introduced additional cleanup logic for form controls and directives. The cleanup logic relies on the presence of ControlValueAccessor instances on FormControlName and FormControl directives. In general these fields are present and there are also checks to make sure that the mentioned directive instances are created with CVAs. However some scenarios (primarily tests) may invoke the logic in a way that the directive instance would not be fully initialized, thus causing CVA to be absent. As a result, the cleanup logic fails while trying to call some methods on associated CVA instances. This commit updates the cleanup logic to take into account the situation when CVA is not present. Fixes #40521. PR Close #40526
…#40526) PR #39235 introduced additional cleanup logic for form controls and directives. The cleanup logic relies on the presence of ControlValueAccessor instances on FormControlName and FormControl directives. In general these fields are present and there are also checks to make sure that the mentioned directive instances are created with CVAs. However some scenarios (primarily tests) may invoke the logic in a way that the directive instance would not be fully initialized, thus causing CVA to be absent. As a result, the cleanup logic fails while trying to call some methods on associated CVA instances. This commit updates the cleanup logic to take into account the situation when CVA is not present. Fixes #40521. PR Close #40526
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Prior to this commit, removing
FormControlDirective
andFormGroupName
directive instances didn't clearthe callbacks previously registered on FromControl/FormGroup class instances. As a result, these callbacks
were executed even after
FormControlDirective
andFormGroupName
directive instances was destroyed. That wasalso causing memory leaks since these callbacks also retained references to DOM elements.
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?