Fix type box losing focus when switching IMEs (#2390)

This commit is contained in:
Hikaru Y 2023-02-22 10:32:16 +09:00 committed by GitHub
parent ec15f1176c
commit 09a946574b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);