mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
mmalerba
parent
a5a8ff25e3
commit
6b4f9c86b2
@@ -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.`);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user