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(select): disabled select being set to touched state on click #5328

Merged
merged 1 commit into from
Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,17 @@ describe('MdSelect', () => {
.toEqual(true, `Expected the control to be touched as soon as focus left the select.`);
});

it('should not set touched when a disabled select is touched', () => {
expect(fixture.componentInstance.control.touched)
.toBe(false, 'Expected the control to start off as untouched.');

fixture.componentInstance.control.disable();
dispatchFakeEvent(trigger, 'blur');

expect(fixture.componentInstance.control.touched)
.toBe(false, 'Expected the control to stay untouched.');
});

it('should set the control to dirty when the select\'s value changes in the DOM', () => {
expect(fixture.componentInstance.control.dirty)
.toEqual(false, `Expected control to start out pristine.`);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
* "blur" to the panel when it opens, causing a false positive.
*/
_onBlur() {
if (!this.panelOpen) {
if (!this.disabled && !this.panelOpen) {
this._onTouched();
}
}
Expand Down