web: Fixed double closed parenthesis on phone

This commit is contained in:
bakk 2021-06-05 12:28:17 +02:00
parent 909b009d5e
commit 0cdecd35b7
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@paddim8/kalk-component",
"version": "1.3.0",
"version": "1.3.1",
"description": "A Svelte component for kalk, a calculator that supports user-defined functions and variables.",
"svelte": "src/main.ts",
"main": "public/build/bundle.js",

View File

@ -46,6 +46,7 @@
let inputElement: HTMLTextAreaElement;
let highlightedTextElement: HTMLElement;
let hasBeenInteractedWith = false;
let ignoreNextInput = false;
function setText(text: string) {
const [highlighted, offset] = highlight(text);
@ -188,6 +189,11 @@
}
function handleInput(e: Event) {
if (ignoreNextInput) {
ignoreNextInput = false;
return;
}
const event = e as InputEvent;
const target = event.target as HTMLInputElement;
setText(target.value == "\n" ? "" : target.value);
@ -249,6 +255,7 @@
input = ", ";
}
ignoreNextInput = true;
inputElement.setRangeText(
input,
inputElement.selectionStart,
@ -256,6 +263,7 @@
"end"
);
setText(inputElement.value);
ignoreNextInput = false;
offsetCaret(offset);
inputElement.focus({ preventScroll: true });
}