From eba0866a34e1d79ecd88e9dd02e2b9ecb00f50f3 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Fri, 27 Jan 2017 15:42:38 -0500 Subject: [PATCH] fix(input): don't allow focus when disabled is set (#10214) Adds the disabled attribute to the parent input/textarea, also fixes where disabled textareas were focusable regardless of where disabled was set fixes #10155 --- src/components/input/input.scss | 2 +- src/components/input/input.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/input/input.scss b/src/components/input/input.scss index 71bd9e1f86b..04ad51c18d3 100644 --- a/src/components/input/input.scss +++ b/src/components/input/input.scss @@ -94,7 +94,7 @@ input.text-input:-webkit-autofill { height: 100%; } -ion-input[disabled] .input-cover { +.input[disabled] .input-cover { pointer-events: none; } diff --git a/src/components/input/input.ts b/src/components/input/input.ts index fffc582a40f..5724949c65b 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -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)); @@ -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 */