From 5722e58c03cc1276561798d00561de52e3374e16 Mon Sep 17 00:00:00 2001 From: Rahul Dubey Date: Mon, 13 Apr 2020 16:06:42 +0530 Subject: [PATCH] fix (android/TextField): set focusable, clickable to false when editable is false 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 --- .../ui/editable-text-base/editable-text-base.android.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.android.ts b/nativescript-core/ui/editable-text-base/editable-text-base.android.ts index 26263e2df3..c81fcfbb26 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.android.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.android.ts @@ -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); } }