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

ngModel / Value Accessor don't play well with OnPush change detection. #12706

Closed
bennadel opened this issue Nov 4, 2016 · 3 comments
Closed

Comments

@bennadel
Copy link

bennadel commented Nov 4, 2016

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Given a 3rd-party component that correctly uses OnPush change detection (since it only renders based on inputs), if you try to communicate with that 3rd-party component using ngModel and a ControlValueAccessor, the component fails to respond to change detection and never triggers the ngOnChanges() life-cycle method.

Expected behavior
When the ControlValueAccessor writes to the 3rd-party component's inputs, it should trigger change detection and the ngOnChanges() life-cycle method. This way, 3rd-party components that you do not have ownership over can be integrated into an ngModel control-flow.

Minimal reproduction of the problem with instructions
Plunkr: https://plnkr.co/edit/oS1qWN7x7nXlQ4oNwR5j?p=preview

In the demo, you'll see that the two components cannot stay in sync. This is because the first one uses input and the second one uses ngModel.

What is the motivation / use case for changing the behavior?
I believe this is a bug that inhibits the ability to consume components that you did not write yourself.

Please tell us about your environment:
Chrome on Plunkr.

  • Angular version: 2.0.X
    This is with whatever Plunkr is currently using for @angular.

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome and Firefox.

  • Language: [all]

  • Node (for AoT issues): node --version =

@pkozlowski-opensource
Copy link
Member

Duplicate of #10816

@bennadel
Copy link
Author

bennadel commented Nov 4, 2016

On snap, my bad. Didn't realize this was already in there.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants