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(button-toggle): toggle group should not emit an initial change event. #1144

Merged
merged 4 commits into from Sep 2, 2016

Conversation

devversion
Copy link
Member

This is the addition of 23a61ab, which was only taking care of the ButtonToggle itself, and not of the group.

Since the md-button-toggle-group does not contain any underlaying input element, and we can't use the emit event if native input does approach, we need to wait for the component view to be ready.

References #1125

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 31, 2016
@colinfang
Copy link

colinfang commented Aug 31, 2016

Just wondering, can we put this._isInitialized = true in ngOnInit? As the property bindings are finished before entering ngOnInit.

@devversion
Copy link
Member Author

@colinfang Yeah that works too. I do not recall why we started using the ngAfterViewInit hook instead.

@jelbourn
Copy link
Member

jelbourn commented Sep 2, 2016

@devversion @colinfang Using ngOnInit does not work because the order of initialization for directives on the same element is not defined. As such, an ngModel on the element may initialize after the ngOnInit of the component itself.

@devversion
Copy link
Member Author

@jelbourn Sounds reasonable. Reverted my commit about the ngOnInit

@jelbourn
Copy link
Member

jelbourn commented Sep 2, 2016

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Sep 2, 2016
@colinfang
Copy link

colinfang commented Sep 2, 2016

@jelbourn Sorry I don't quite follow up, I have never made a ngModel for a custom component before. Could you please elaborate a little bit more?

Are you saying in

 <my-component  [ngModel]="abc" ></my-component>

At MyComponent.ngOnInit, the value of myInput may not be assigned if ngModel is mapped to a property say Output() myInput?

@jelbourn
Copy link
Member

jelbourn commented Sep 2, 2016

@colinfang when you have an ngModel, it can be responsible for initializing the component, so you want to set isInitialized = true after ngModel has run, which can be after the component's onInit.

@kara kara merged commit e5830d1 into angular:master Sep 2, 2016
@devversion devversion deleted the fix/button-toggle-change-event branch September 2, 2016 17:11
@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 6, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants