web: Fixed caret position offset on button press input

This commit is contained in:
bakk 2021-06-05 00:29:05 +02:00
parent df1eef8e7f
commit adc5e14fec

View File

@ -217,10 +217,12 @@
let offset = 0;
if (input == "(") {
input += ")";
offset = -1;
} else if (input == "=") {
input = " = ";
} else if (input == "∑") {
input += "()";
offset = -1;
} else if (input == "∫") {
input += "()";
offset = -1;
@ -240,8 +242,9 @@
inputElement.selectionEnd,
"end"
);
inputElement.selectionEnd += offset;
setText(inputElement.value);
inputElement.selectionStart += offset;
inputElement.selectionEnd = inputElement.selectionStart;
inputElement.focus({ preventScroll: true });
}