Skip to content

Commit

Permalink
fix(input): don't allow focus when disabled is set (#10214)
Browse files Browse the repository at this point in the history
Adds the disabled attribute to the parent input/textarea, also fixes
where disabled textareas were focusable regardless of where disabled
was set

fixes #10155
  • Loading branch information
brandyscarney authored and jgw96 committed Jan 27, 2017
1 parent d3f4bc0 commit eba0866
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ input.text-input:-webkit-autofill {
height: 100%;
}

ion-input[disabled] .input-cover {
.input[disabled] .input-cover {
pointer-events: none;
}

Expand Down
10 changes: 9 additions & 1 deletion src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class TextInput extends Ion implements IonicFormInput {
*/
@Input()
get disabled() {
return this.ngControl ? this.ngControl.disabled : this._disabled;
return this._disabled;
}
set disabled(val: boolean) {
this.setDisabled(this._disabled = isTrueProperty(val));
Expand All @@ -226,10 +226,18 @@ export class TextInput extends Ion implements IonicFormInput {
* @private
*/
setDisabled(val: boolean) {
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'disabled', val ? '' : null);
this._item && this._item.setElementClass('item-input-disabled', val);
this._native && this._native.isDisabled(val);
}

/**
* @private
*/
setDisabledState(isDisabled: boolean) {
this.disabled = isDisabled;
}

/**
* @input {boolean} If the input should be readonly or not
*/
Expand Down

0 comments on commit eba0866

Please sign in to comment.