fix(select): disabled select being set to touched state on click (#5328)

Fixes being able to set a disabled `md-select` to `touched` by clicking on it.
This commit is contained in:
Kristiyan Kostadinov
2017-07-07 19:04:07 +02:00
committed by mmalerba
parent a5a8ff25e3
commit 6b4f9c86b2
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -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.`);
+1 -1
View File
@@ -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();
}
}