Skip to content

Commit

Permalink
fix(select): disabled select being set to touched state on click (#5328)
Browse files Browse the repository at this point in the history
Fixes being able to set a disabled `md-select` to `touched` by clicking on it.
  • Loading branch information
crisbeto authored and mmalerba committed Jul 7, 2017
1 parent a5a8ff2 commit 6b4f9c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/lib/select/select.spec.ts
Expand Up @@ -635,6 +635,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
Expand Up @@ -534,7 +534,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

0 comments on commit 6b4f9c8

Please sign in to comment.