From e496cf84bcac8f6275d674f78528c8e66d6aef6d Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Tue, 7 Mar 2023 09:27:41 +0100 Subject: [PATCH] push browser workaround to the end of the method --- assets/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/assets/index.js b/assets/index.js index e0f15c9..82e0ae1 100644 --- a/assets/index.js +++ b/assets/index.js @@ -62,14 +62,6 @@ function onSelectionChange() { function onInput(event) { 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 = { client: uuid, action: event.inputType, @@ -81,6 +73,14 @@ function onInput(event) { ws.send(JSON.stringify(payload)); 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();