From de605ecd02937347d8a122de4724febf9e3c97f1 Mon Sep 17 00:00:00 2001 From: Victor Sales <36749678+v1ctorsales@users.noreply.github.com> Date: Sat, 31 May 2025 01:45:32 -0300 Subject: [PATCH] rename plusDisabled and add ARIA attributes for accessible plus-button --- src/renderer/src/pages/catalogue/game-item.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/pages/catalogue/game-item.tsx b/src/renderer/src/pages/catalogue/game-item.tsx index 28d9dc9f..0a89eaa5 100644 --- a/src/renderer/src/pages/catalogue/game-item.tsx +++ b/src/renderer/src/pages/catalogue/game-item.tsx @@ -26,7 +26,7 @@ export function GameItem({ game }: GameItemProps) { const repacks = getRepacksForObjectId(game.objectId); - const [plusDisabled, setPlusDisabled] = useState(false); + const [_plusDisabled, setPlusDisabled] = useState(false); const [added, setAdded] = useState(false); @@ -42,9 +42,9 @@ export function GameItem({ game }: GameItemProps) { } }, [library, game.shop, game.objectId]); - const addGameToLibrary = async (event: React.MouseEvent) => { + const addGameToLibrary = async (event: React.MouseEvent | React.KeyboardEvent) => { event.stopPropagation(); - if (added) return; + if (added || _plusDisabled) return; setPlusDisabled(true); try { @@ -72,7 +72,7 @@ export function GameItem({ game }: GameItemProps) { (steamGenre) => steamGenre === genre ); - if (index && steamGenres[language] && steamGenres[language][index]) { + if (index !== undefined && steamGenres[language] && steamGenres[language][index]) { return steamGenres[language][index]; } @@ -119,7 +119,15 @@ export function GameItem({ game }: GameItemProps) {