Skip to content

Commit 1ba78b0

Browse files
Refactor file selection logic to prevent event propagation and ensure async handling (#444)
1 parent 8928f5b commit 1ba78b0

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/main/frontend/app/components/git/git-changes.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,14 @@ function FileSection({
112112
)}
113113
onClick={() => onSelectFile(file)}
114114
>
115-
<IndeterminateCheckbox
116-
checked={checkboxChecked}
117-
indeterminate={checkboxIndeterminate}
118-
onChange={() => onToggleFile(file)}
119-
title={checkboxChecked ? 'Deselect all chunks' : 'Select all chunks'}
120-
/>
115+
<div onClick={(e) => e.stopPropagation()}>
116+
<IndeterminateCheckbox
117+
checked={checkboxChecked}
118+
indeterminate={checkboxIndeterminate}
119+
onChange={() => onToggleFile(file)}
120+
title={checkboxChecked ? 'Deselect all chunks' : 'Select all chunks'}
121+
/>
122+
</div>
121123
<span
122124
className={clsx(
123125
'flex h-4 w-4 flex-shrink-0 items-center justify-center rounded text-[10px] font-bold',

src/main/frontend/app/components/git/git-panel.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ export default function GitPanel({ projectName, hasStoredToken }: GitPanelProps)
8484
)
8585

8686
const handleToggleFile = useCallback(
87-
(filePath: string) => {
87+
async (filePath: string) => {
8888
const hunkState = useGitStore.getState().fileHunkStates[filePath]
8989
if (!hunkState || hunkState.totalHunks === 0) {
90-
handleSelectFile(filePath)
91-
return
90+
await handleSelectFile(filePath)
9291
}
93-
if (hunkState.selectedHunks.size === hunkState.totalHunks) {
92+
93+
const updatedState = useGitStore.getState().fileHunkStates[filePath]
94+
if (updatedState.selectedHunks.size === updatedState.totalHunks) {
9495
clearFileHunks(filePath)
9596
} else {
9697
selectAllFileHunks(filePath)

0 commit comments

Comments
 (0)