From 50810a08e5a767ec6d774996ce13244121b9f3c3 Mon Sep 17 00:00:00 2001
From: xXJSONDeruloXx <danielhimebauch@gmail.com>
Date: Mon, 7 Sep 2026 00:39:16 -0400
Subject: fix: improve profile management focus and reset confirmation

---
 src/components/ConfigurationTab.tsx | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

(limited to 'src/components/ConfigurationTab.tsx')

diff --git a/src/components/ConfigurationTab.tsx b/src/components/ConfigurationTab.tsx
index 6c4a99a..0d8553c 100644
--- a/src/components/ConfigurationTab.tsx
+++ b/src/components/ConfigurationTab.tsx
@@ -28,13 +28,25 @@ export function ConfigurationTab({
 }: ConfigurationTabProps) {
   const [detailAppId, setDetailAppId] = useState<string | null>(null);
   const [focusFpsMultiplier, setFocusFpsMultiplier] = useState(false);
+  const [focusBackToGames, setFocusBackToGames] = useState(false);
+  const backToGamesRef = useRef<HTMLDivElement>(null);
   const promptedRunningAppId = useRef<string | null>(null);
   const closeDetails = useCallback(() => {
     setFocusFpsMultiplier(false);
+    setFocusBackToGames(false);
     setDetailAppId(null);
   }, []);
   const clearFpsFocusRequest = useCallback(() => setFocusFpsMultiplier(false), []);
 
+  useEffect(() => {
+    if (!focusBackToGames) return;
+    const frame = requestAnimationFrame(() => {
+      backToGamesRef.current?.querySelector<HTMLElement>('[role="button"]')?.focus();
+      setFocusBackToGames(false);
+    });
+    return () => cancelAnimationFrame(frame);
+  }, [focusBackToGames]);
+
   useEffect(() => {
     if (!runningGame || runningGame.configured) {
       promptedRunningAppId.current = null;
@@ -55,6 +67,7 @@ export function ConfigurationTab({
           targets={targets}
           runningGame={runningGame}
           onSelect={(appid) => {
+            setFocusBackToGames(true);
             onSelect(appid);
             setDetailAppId(appid);
           }}
@@ -76,7 +89,9 @@ export function ConfigurationTab({
           <Field label={profileLabel} description={profileDescription} />
         </PanelSectionRow>
         <PanelSectionRow>
-          <ButtonItem layout="below" onClick={closeDetails}>Back to games</ButtonItem>
+          <Focusable ref={backToGamesRef} noFocusRing>
+            <ButtonItem layout="below" onClick={closeDetails}>Back to games</ButtonItem>
+          </Focusable>
         </PanelSectionRow>
       </PanelSection>
       {selectedTarget?.configured && (
-- 
cgit v1.2.3

