From 0c538f74a544014d26ff0dabe082ee427c6fad44 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 20 Mar 2024 11:58:28 +0100 Subject: [PATCH] Try to detect when Safari fails to fire a compositionend event FIX: Fix the editor getting stuck in composition when Safari fails to fire a compositionend event for a dead key composition. Issue https://github.com/codemirror/dev/issues/1324 --- src/input.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/input.ts b/src/input.ts index bf21dcd..88f5cdd 100644 --- a/src/input.ts +++ b/src/input.ts @@ -877,6 +877,11 @@ handlers.beforeinput = (view, event) => { // keyboard. view.observer.flushSoon() } + // Safari will occasionally forget to fire compositionend at the end of a dead-key composition + if (browser.safari && event.inputType == "insertText" && view.inputState.composing >= 0) { + setTimeout(() => observers.compositionend(view, event), 20) + } + return false }