diff --git a/web/src/KalkCalculator.svelte b/web/src/KalkCalculator.svelte index 737f02b..659753c 100644 --- a/web/src/KalkCalculator.svelte +++ b/web/src/KalkCalculator.svelte @@ -53,7 +53,7 @@ History, } - function setText(text: string, isFinalBeforeSubmit = false) { + function setText(text: string, isFinalBeforeSubmit = false, isComposing = false) { const [highlighted, offset] = highlight( text, isFinalBeforeSubmit @@ -62,7 +62,9 @@ ); const prevCursorPos = inputElement.selectionStart; setHtml(highlighted); - setCaret(prevCursorPos + offset); + if(!isComposing){ + setCaret(prevCursorPos + offset); + } } function setHtml(html: string) { @@ -226,7 +228,7 @@ const event = e as InputEvent; const target = event.target as HTMLInputElement; - setText(target.value == "\n" ? "" : target.value); + setText(target.value == "\n" ? "" : target.value, undefined, event.isComposing); if (event.data == "(") { insertText(")");