fix (android/TextField): set focusable, clickable to false when editable is false (#8525)

Do not clear key listener when editable is false This prevents the input type to be changed.
Instead, we can set focusable, clickable to false.
This allows to change input Type i.e (secure) at run time when editable is false.

Reference issue: https://github.com/NativeScript/NativeScript/issues/8523

Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
This commit is contained in:
Rahul Dubey
2020-04-14 15:06:54 +05:30
committed by GitHub
parent 7cf3c978fd
commit 50e58fa19f

View File

@ -227,9 +227,13 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
this._keyListenerCache = listener;
}
// clear the listener if editable is false
// clear these fields instead of clearing listener.
// this allows input Type to be changed even after editable is false.
if (!this.editable) {
nativeView.setKeyListener(null);
nativeView.setFocusable(false);
nativeView.setFocusableInTouchMode(false);
nativeView.setLongClickable(false);
nativeView.setClickable(false);
}
}