Skip to content

Commit eba0866

Browse files
brandyscarneyjgw96
authored andcommitted
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
1 parent d3f4bc0 commit eba0866

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/components/input/input.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ input.text-input:-webkit-autofill {
9494
height: 100%;
9595
}
9696

97-
ion-input[disabled] .input-cover {
97+
.input[disabled] .input-cover {
9898
pointer-events: none;
9999
}
100100

src/components/input/input.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class TextInput extends Ion implements IonicFormInput {
216216
*/
217217
@Input()
218218
get disabled() {
219-
return this.ngControl ? this.ngControl.disabled : this._disabled;
219+
return this._disabled;
220220
}
221221
set disabled(val: boolean) {
222222
this.setDisabled(this._disabled = isTrueProperty(val));
@@ -226,10 +226,18 @@ export class TextInput extends Ion implements IonicFormInput {
226226
* @private
227227
*/
228228
setDisabled(val: boolean) {
229+
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'disabled', val ? '' : null);
229230
this._item && this._item.setElementClass('item-input-disabled', val);
230231
this._native && this._native.isDisabled(val);
231232
}
232233

234+
/**
235+
* @private
236+
*/
237+
setDisabledState(isDisabled: boolean) {
238+
this.disabled = isDisabled;
239+
}
240+
233241
/**
234242
* @input {boolean} If the input should be readonly or not
235243
*/

0 commit comments

Comments
 (0)