fix(select): make floating labels work for ion-select

fixes #10751
This commit is contained in:
Ibrahim Ghazal
2017-03-14 12:42:12 +03:00
parent 446e468b59
commit 8c483f2529
4 changed files with 42 additions and 4 deletions

View File

@ -387,6 +387,21 @@ export class Select extends Ion implements AfterContentInit, ControlValueAccesso
return (this._multi ? this._texts : this._texts.join());
}
/**
* @private
*/
checkHasValue(inputValue: any) {
if (this._item) {
let hasValue: boolean;
if (Array.isArray(inputValue)) {
hasValue = inputValue.length > 0;
} else {
hasValue = !isBlank(inputValue);
}
this._item.setElementClass('input-has-value', hasValue);
}
}
/**
* @private
*/
@ -445,6 +460,7 @@ export class Select extends Ion implements AfterContentInit, ControlValueAccesso
console.debug('select, writeValue', val);
this._values = (Array.isArray(val) ? val : isBlank(val) ? [] : [val]);
this._updOpts();
this.checkHasValue(val);
}
/**
@ -464,6 +480,7 @@ export class Select extends Ion implements AfterContentInit, ControlValueAccesso
fn(val);
this._values = (Array.isArray(val) ? val : isBlank(val) ? [] : [val]);
this._updOpts();
this.checkHasValue(val);
this.onTouched();
};
}
@ -481,6 +498,7 @@ export class Select extends Ion implements AfterContentInit, ControlValueAccesso
console.debug('select, onChange w/out formControlName', val);
this._values = (Array.isArray(val) ? val : isBlank(val) ? [] : [val]);
this._updOpts();
this.checkHasValue(val);
this.onTouched();
}