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

feat(select): emit change event #2458

Merged
merged 4 commits into from
Jan 12, 2017

Conversation

crisbeto
Copy link
Member

Adds an event to md-select that is emitted when the selected option has changed.

Fixes #2248.

@crisbeto crisbeto requested a review from kara December 29, 2016 14:12
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 29, 2016
Adds an event to `md-select` that is emitted when the selected option has changed.

Fixes angular#2248.
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Looks good, just needs some minor updates to the examples in demo/tests.

@@ -3,7 +3,7 @@
<div class="demo-select">
<div *ngIf="showSelect">
<md-card>
<md-select placeholder="Food i would like to eat" [formControl]="foodControl">
<md-select placeholder="Food i would like to eat" [formControl]="foodControl" (change)="changeListener($event)">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make a separate demo for the change event that does not use a form directive? The change event is only intended for people not using Angular forms modules, since these already have their own built-in change events. Just don't want to confuse the intended usage with this example.

@@ -237,6 +237,27 @@ describe('MdSelect', () => {
expect(fixture.componentInstance.select.selected).not.toBeDefined();
});


it('should emit an event when the selected option has changed', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have its own test component that doesn't use a form module directive

@crisbeto
Copy link
Member Author

Addressed the feedback @kara.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

One minor change, then should be good

});

@Component({
selector: 'basic-select',
template: `
<div [style.height.px]="heightAbove"></div>
<md-select placeholder="Food" [formControl]="control" [required]="isRequired">
<md-select placeholder="Food" [formControl]="control" [required]="isRequired"
(change)="changeListener($event)">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the change event and listener from the basic select component? It should only be in the new test component.

@crisbeto
Copy link
Member Author

crisbeto commented Jan 4, 2017

Fixed @kara, not sure how I forgot to remove the last one.

@@ -1169,6 +1201,7 @@ class BasicSelect {
isRequired: boolean;
heightAbove = 0;
heightBelow = 0;
changeListener = jasmine.createSpy('MdSelect change listener');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove this too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, done.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@kara
Copy link
Contributor

kara commented Jan 12, 2017

@crisbeto Is this ready to merge? Just noticed it doesn't have the label.

@crisbeto
Copy link
Member Author

It is, I'm not sure who's supposed to add the label.

@kara
Copy link
Contributor

kara commented Jan 12, 2017

@crisbeto Since you are the author and a member of the repo, you are the one that adds the "merge ready" label :) "LGTM" just means that it's approved; "merge ready" means that the author has made all the changes they wanted to.

@kara kara added the action: merge The PR is ready for merge by the caretaker label Jan 12, 2017
@tinayuangao tinayuangao merged commit e5bd15c into angular:master Jan 12, 2017
@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.

Bug - select not firing change event
4 participants