Clear focus on Game Bar after activating it

This commit is contained in:
redphx 2024-09-06 17:03:55 +07:00
parent 4d90ebca68
commit 756d105f74
2 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { CE, createSvgIcon } from "@utils/html"; import { CE, clearFocus, createSvgIcon } from "@utils/html";
import { ScreenshotAction } from "./action-screenshot"; import { ScreenshotAction } from "./action-screenshot";
import { TouchControlAction } from "./action-touch-control"; import { TouchControlAction } from "./action-touch-control";
import { BxEvent } from "@utils/bx-event"; import { BxEvent } from "@utils/bx-event";
@ -133,6 +133,9 @@ export class GameBar {
} }
hideBar() { hideBar() {
// Stop focusing Game Bar
clearFocus();
if (!this.$container) { if (!this.$container) {
return; return;
} }

View File

@ -174,3 +174,9 @@ export function removeChildElements($parent: HTMLElement) {
$parent.firstElementChild.remove(); $parent.firstElementChild.remove();
} }
} }
export function clearFocus() {
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
}
}