push browser workaround to the end of the method

This commit is contained in:
Sebastian Hugentobler 2023-03-07 09:27:41 +01:00
parent 090f3bcb23
commit e496cf84bc
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0

View File

@ -62,14 +62,6 @@ function onSelectionChange() {
function onInput(event) { function onInput(event) {
if (!validEvents.includes(event.inputType)) return; if (!validEvents.includes(event.inputType)) return;
// workaround for differences between firefox and chrome
// chrome does not fire selectionchange events on backspace/delete events,
// while firefox does
if (event.inputType === "deleteContentBackward") {
selectionStart = area.selectionStart;
selectionEnd = area.selectionEnd;
}
const payload = { const payload = {
client: uuid, client: uuid,
action: event.inputType, action: event.inputType,
@ -81,6 +73,14 @@ function onInput(event) {
ws.send(JSON.stringify(payload)); ws.send(JSON.stringify(payload));
console.log(selectionStart, selectionEnd); console.log(selectionStart, selectionEnd);
// workaround for differences between firefox and chrome
// chrome does not fire selectionchange events on backspace/delete events,
// while firefox does
if (event.inputType === "deleteContentBackward") {
selectionStart = area.selectionStart - 1;
selectionEnd = area.selectionEnd - 1;
}
} }
setup(); setup();