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

This commit is contained in:
UnknownShadow200 2021-05-16 16:01:25 +10:00
parent b8b29dfb07
commit 629b44b038

View File

@ -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);
var cur = window.cc_inputElem.value;
if (str == window.cc_inputElem.value) return;
window.cc_inputElem.value = str;
if (cur.length && cur[cur.length - 1] == '\n') { cur = cur.substring(0, cur.length - 1); }
if (str != cur) window.cc_inputElem.value = str;
}, text);
}