Skip to content

Commit

Permalink
focus refresh button after refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
beebls committed Oct 12, 2024
1 parent ba538cf commit 8d4c62c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/modules/qam-tab-page/components/QamRefreshButton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import { ButtonItem, PanelSectionRow } from "@decky/ui";
import { useCSSLoaderAction, useCSSLoaderValue } from "@/backend";
import { useEffect, useRef } from "react";

export function QamRefreshButton() {
const reloadPlugin = useCSSLoaderAction("reloadPlugin");
const isWorking = useCSSLoaderValue("isWorking");

const refreshButtonRef = useRef<HTMLButtonElement>(null);

useEffect(() => {
console.log(refreshButtonRef.current);
});

async function handleRefresh() {
await reloadPlugin();
// This just ensures focus isn't lost
refreshButtonRef.current?.focus();
}

return (
<PanelSectionRow>
<ButtonItem
// @ts-ignore Not typed currently
ref={refreshButtonRef}
disabled={isWorking}
onClick={() => {
console.log("TEST");
void reloadPlugin();
void handleRefresh();
}}
layout="below"
>
Expand Down

0 comments on commit 8d4c62c

Please sign in to comment.