From 09a946574b2c4410d772330ee03e2235fdf4799a Mon Sep 17 00:00:00 2001 From: Hikaru Y Date: Wed, 22 Feb 2023 10:32:16 +0900 Subject: [PATCH] Fix type box losing focus when switching IMEs (#2390) --- ts/reviewer/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ts/reviewer/index.ts b/ts/reviewer/index.ts index 17c57f5e0..c382f5182 100644 --- a/ts/reviewer/index.ts +++ b/ts/reviewer/index.ts @@ -249,6 +249,11 @@ const dummyButton = document.createElement("button"); dummyButton.style.position = "absolute"; dummyButton.style.left = "-9999px"; document.addEventListener("focusout", (event) => { + // Prevent type box from losing focus when switching IMEs + if (!document.hasFocus()) { + return; + } + const target = event.target; if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) { document.body.appendChild(dummyButton);