From 756d105f74d2ea2b66251107e5cb83a70315f6d5 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:03:55 +0700 Subject: [PATCH] Clear focus on Game Bar after activating it --- src/modules/game-bar/game-bar.ts | 5 ++++- src/utils/html.ts | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/game-bar/game-bar.ts b/src/modules/game-bar/game-bar.ts index b7be891..5a966b1 100644 --- a/src/modules/game-bar/game-bar.ts +++ b/src/modules/game-bar/game-bar.ts @@ -1,4 +1,4 @@ -import { CE, createSvgIcon } from "@utils/html"; +import { CE, clearFocus, createSvgIcon } from "@utils/html"; import { ScreenshotAction } from "./action-screenshot"; import { TouchControlAction } from "./action-touch-control"; import { BxEvent } from "@utils/bx-event"; @@ -133,6 +133,9 @@ export class GameBar { } hideBar() { + // Stop focusing Game Bar + clearFocus(); + if (!this.$container) { return; } diff --git a/src/utils/html.ts b/src/utils/html.ts index 9a7b6c6..10a436d 100644 --- a/src/utils/html.ts +++ b/src/utils/html.ts @@ -174,3 +174,9 @@ export function removeChildElements($parent: HTMLElement) { $parent.firstElementChild.remove(); } } + +export function clearFocus() { + if (document.activeElement instanceof HTMLElement) { + document.activeElement.blur(); + } +}