From ca444aa8ed0d555fcd225fa664a0b1885436fb17 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Wed, 16 May 2018 15:13:09 +0300 Subject: [PATCH] fix(android-textfield): returnPress fired twice for GO/SEARCH/SEND (#5727) --- .../editable-text-base.android.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tns-core-modules/ui/editable-text-base/editable-text-base.android.ts b/tns-core-modules/ui/editable-text-base/editable-text-base.android.ts index c4c0a999e..e7c54d190 100644 --- a/tns-core-modules/ui/editable-text-base/editable-text-base.android.ts +++ b/tns-core-modules/ui/editable-text-base/editable-text-base.android.ts @@ -115,12 +115,8 @@ function initializeEditTextListeners(): void { return false; } - if (actionId === android.view.inputmethod.EditorInfo.IME_NULL || + if (actionId === android.view.inputmethod.EditorInfo.IME_ACTION_DONE || actionId === android.view.inputmethod.EditorInfo.IME_ACTION_UNSPECIFIED || - actionId === android.view.inputmethod.EditorInfo.IME_ACTION_DONE || - actionId === android.view.inputmethod.EditorInfo.IME_ACTION_GO || - actionId === android.view.inputmethod.EditorInfo.IME_ACTION_SEARCH || - actionId === android.view.inputmethod.EditorInfo.IME_ACTION_SEND || (event && event.getKeyCode() === android.view.KeyEvent.KEYCODE_ENTER)) { // If it is TextField, close the keyboard. If it is TextView, do not close it since the TextView is multiline // https://github.com/NativeScript/NativeScript/issues/3111 @@ -129,11 +125,9 @@ function initializeEditTextListeners(): void { } owner._onReturnPress(); - } - - // If action is ACTION_NEXT then do not close keyboard - if (actionId === android.view.inputmethod.EditorInfo.IME_ACTION_NEXT - || actionId === android.view.inputmethod.EditorInfo.IME_ACTION_PREVIOUS) { + } else if (actionId === android.view.inputmethod.EditorInfo.IME_ACTION_NEXT || + actionId === android.view.inputmethod.EditorInfo.IME_ACTION_PREVIOUS) { + // do not close keyboard for ACTION_NEXT or ACTION_PREVIOUS owner._onReturnPress(); }