Skip to content

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

Merged
josephperrott merged 1 commit into
angular:masterfrom
crisbeto:11812/slide-toggle-change-event
Jun 28, 2018
Merged

josephperrott merged 1 commit into
angular:masterfrom
crisbeto:11812/slide-toggle-change-event

Conversation

@crisbeto

@crisbeto crisbeto commented Jun 19, 2018 •

Copy link
Copy Markdown
Member

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

Fixes #11812.

@crisbeto
crisbeto requested a review from devversion as a code owner June 19, 2018 17:53
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 19, 2018
@devversion

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Member Author

Changed.

@devversion devversion left a comment

Copy link
Copy Markdown
Member

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

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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