From 81dc2ab946e69e205fb0a2815ba0af7e8e50eac6 Mon Sep 17 00:00:00 2001 From: Mateus Ribeiro Date: Fri, 21 Aug 2026 18:11:59 -0300 Subject: [PATCH 1/2] fix : copy the wrong game PGN after a deletion The DataGrid is fed `rows={games}` with no `getRowId`, so it derives row ids from `Game.id`, which is the IndexedDB auto-increment key. `handleCopyGameRow` treated that key as an array index (`games[id - 1]`). Keys stay dense only until a game is deleted. After that they go sparse (1, 2, 4, 5...) while the array stays contiguous, so copying a game whose id sits past the gap yields another game's PGN, or throws on `undefined.pgn` for the last row. Look the game up by key instead, matching what `handleDeleteGameRow` already does with the same value. --- src/pages/database.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/database.tsx b/src/pages/database.tsx index d6bff021..0535a3cb 100644 --- a/src/pages/database.tsx +++ b/src/pages/database.tsx @@ -41,7 +41,11 @@ export default function GameDatabase() { if (typeof id !== "number") { throw new Error("Unable to copy game"); } - await navigator.clipboard?.writeText?.(games[id - 1].pgn); + const game = games.find((g) => g.id === id); + if (!game) { + throw new Error(`Game ${id} not found`); + } + await navigator.clipboard?.writeText?.(game.pgn); }, [games] ); From a3fb1657c6f6c40a76843cd07a313f9a151b171a Mon Sep 17 00:00:00 2001 From: Mateus Ribeiro Date: Fri, 21 Aug 2026 18:12:19 -0300 Subject: [PATCH 2/2] chore : remove leftover debug log from the database page --- src/pages/database.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/database.tsx b/src/pages/database.tsx index 0535a3cb..2e8e231e 100644 --- a/src/pages/database.tsx +++ b/src/pages/database.tsx @@ -24,8 +24,6 @@ export default function GameDatabase() { const { games, deleteGame } = useGameDatabase(true); const router = useRouter(); - console.log(games); - const handleDeleteGameRow = useCallback( (id: GridRowId) => async () => { if (typeof id !== "number") {