From 629b44b038119080e104b73dba33534785dc2be1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 16 May 2021 16:01:25 +1000 Subject: [PATCH] Mobile webclient: Fix pressing 'Go' button on on-screen keyboard on android chrome repeatedly not actually sending chat until you had clicked one of the text prediction suggestions --- src/interop_web.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/interop_web.c b/src/interop_web.c index 94c102133..766af040a 100644 --- a/src/interop_web.c +++ b/src/interop_web.c @@ -318,13 +318,15 @@ void interop_OpenKeyboard(const char* text, int type, const char* placeholder) { }, text, type, placeholder); } +/* NOTE: When pressing 'Go' on the on-screen keyboard, web browser adds \n to value */ void interop_SetKeyboardText(const char* text) { EM_ASM_({ if (!window.cc_inputElem) return; var str = UTF8ToString($0); - - if (str == window.cc_inputElem.value) return; - window.cc_inputElem.value = str; + var cur = window.cc_inputElem.value; + + if (cur.length && cur[cur.length - 1] == '\n') { cur = cur.substring(0, cur.length - 1); } + if (str != cur) window.cc_inputElem.value = str; }, text); }