Skip to content

fix(button-toggle): dirty on load when used with ngModel #4898

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

Closed

Conversation

crisbeto
Copy link
Member

Fixes the button toggle group being marked as dirty on load, if it has a ControlValueAccessor and an initial value.

Fixes #4888.

Fixes the button toggle group being marked as dirty on load, if it has a ControlValueAccessor and an initial value.

Fixes angular#4888.
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 31, 2017
Copy link
Contributor

@tinayuangao tinayuangao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jun 7, 2017
@kara kara added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Jun 12, 2017
@kara
Copy link
Contributor

kara commented Jun 12, 2017

@crisbeto It seems to me that the underlying problem is that value changes from any source lead to the forms API onChange function being called (which sets the control to dirty), rather than only user-generated value changes. Deferring the setting of the isInitialized property avoids the initial call, but any programmatic writes after that will still improperly mark the control as dirty. Can we pass a boolean into the _emitChangeEvent method for whether it was user-generated, then only call the forms API change function in that case?

@kara kara removed the action: merge The PR is ready for merge by the caretaker label Jun 12, 2017
@jelbourn
Copy link
Member

@crisbeto is this worth revisiting?

@crisbeto
Copy link
Member Author

Yeah it's been on my TODO list, but I was waiting for the refactoring to get in.

@jelbourn
Copy link
Member

Ack, we just have some failing tests in Firebase on the refactor I need to debug. Poke me on this when it's resolved

@josephperrott
Copy link
Member

@crisbeto Please rebase when you have a chance.

@crisbeto
Copy link
Member Author

Looks like the original issue got fixed by #9191. Closing.

@crisbeto crisbeto closed this Mar 31, 2018
@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

md-button-toggle-group starts off as dirty
6 participants