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

fix(slide-toggle): not updating model from toggle method #11846

Merged

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jun 19, 2018

Fixes the slide toggle not propagating its value to the ControlValueAccessor when its value is changed through the toggle method.

Fixes #11812.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 19, 2018
@devversion
Copy link
Member

I think we intentionally didn't emit the event when someone programmatically calls toggle() or changes the checked value, because native input element's don't do either.

@crisbeto
Copy link
Member Author

We definitely need to call at least onChange, otherwise it won't update the ngModel. Also judging by the should support subscription on the change observable test, it seems like we were expecting it to be emitted.

@devversion
Copy link
Member

Yeah, I think calling onChange to propagate the change to the ControlValueAccessor makes sense. Although, I'm not sure whether we should really emit the change event. Otherwise we might need to also take into account, that people just change the checked property.

@jelbourn
Copy link
Member

We shouldn't emit a change event unless there was a user interaction, similar to the native checkbox. I think mat-checkbox behaves this way.

Fixes the slide toggle not propagating its value to the `ControlValueAccessor` when its value is changed through the `toggle` method.

Fixes angular#11812.
@crisbeto crisbeto changed the title fix(slide-toggle): not updating model or dispatching change event from toggle method fix(slide-toggle): not updating model from toggle method Jun 19, 2018
@crisbeto crisbeto force-pushed the 11812/slide-toggle-change-event branch from 4102f25 to 41aa96b Compare June 19, 2018 19:55
@crisbeto
Copy link
Member Author

Changed.

Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM now.

@devversion devversion added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jun 19, 2018
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mat-slide-toggle component's toggle() method does not emit change event
5 participants