From 3cba7edcf849d85b60196fd4c0c4b8fa4adfc782 Mon Sep 17 00:00:00 2001 From: stijnpotters Date: Tue, 21 Apr 2026 13:29:49 +0200 Subject: [PATCH] Refactor file selection logic to prevent event propagation and ensure async handling --- .../frontend/app/components/git/git-changes.tsx | 14 ++++++++------ src/main/frontend/app/components/git/git-panel.tsx | 9 +++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/frontend/app/components/git/git-changes.tsx b/src/main/frontend/app/components/git/git-changes.tsx index 201bcd14..67d13752 100644 --- a/src/main/frontend/app/components/git/git-changes.tsx +++ b/src/main/frontend/app/components/git/git-changes.tsx @@ -112,12 +112,14 @@ function FileSection({ )} onClick={() => onSelectFile(file)} > - onToggleFile(file)} - title={checkboxChecked ? 'Deselect all chunks' : 'Select all chunks'} - /> +
e.stopPropagation()}> + onToggleFile(file)} + title={checkboxChecked ? 'Deselect all chunks' : 'Select all chunks'} + /> +
{ + async (filePath: string) => { const hunkState = useGitStore.getState().fileHunkStates[filePath] if (!hunkState || hunkState.totalHunks === 0) { - handleSelectFile(filePath) - return + await handleSelectFile(filePath) } - if (hunkState.selectedHunks.size === hunkState.totalHunks) { + + const updatedState = useGitStore.getState().fileHunkStates[filePath] + if (updatedState.selectedHunks.size === updatedState.totalHunks) { clearFileHunks(filePath) } else { selectAllFileHunks(filePath)