Skip to content

Commit 091398a

Browse files
authored
fix: Fix single-select checkbox state in planning mode (#1312)
## Problem In single-select mode, clicking the "Other" option enters edit mode without clearing the previous selection, and typing auto-checks "Other" without clearing others so you end up with two items checked. Then you can't uncheck either because single-select toggleCheck always re-selects the clicked item. ![image.png](https://app.graphite.com/user-attachments/assets/463a9513-6a82-4370-8e52-1da252522d63.png) ## Changes 1. Allow unchecking a selected option in single-select mode (toggleCheck) 2. Clear other selections when clicking a custom-input option in single-select mode (handleClick, selectCurrent) 3. Clear other selections when auto-checking custom input on text entry in single-select mode (handleCustomInputChange) ## How did you test this? Manually
1 parent eb89c54 commit 091398a

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

apps/code/src/renderer/components/action-selector/useActionSelectorState.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ export function useActionSelectorState({
173173
next.add(optionId);
174174
}
175175
} else {
176-
next.clear();
177-
next.add(optionId);
176+
if (next.has(optionId)) {
177+
next.clear();
178+
} else {
179+
next.clear();
180+
next.add(optionId);
181+
}
178182
}
179183
return next;
180184
});
@@ -227,6 +231,9 @@ export function useActionSelectorState({
227231

228232
if (showSubmitButton) {
229233
if (needsCustomInput(selected) && !isEditing) {
234+
if (!multiSelect) {
235+
setCheckedOptions(new Set());
236+
}
230237
setIsEditing(true);
231238
} else {
232239
toggleCheck(selected.id);
@@ -330,6 +337,9 @@ export function useActionSelectorState({
330337

331338
if (showSubmitButton) {
332339
if (needsCustomInput(selected)) {
340+
if (!multiSelect) {
341+
setCheckedOptions(new Set());
342+
}
333343
setIsEditing(true);
334344
} else {
335345
toggleCheck(selected.id);
@@ -382,6 +392,9 @@ export function useActionSelectorState({
382392
const next = new Set(prev);
383393
if (value.trim()) {
384394
if (!prev.has(selectedOption.id)) {
395+
if (!multiSelect) {
396+
next.clear();
397+
}
385398
next.add(selectedOption.id);
386399
}
387400
} else {
@@ -391,7 +404,7 @@ export function useActionSelectorState({
391404
});
392405
}
393406
},
394-
[showSubmitButton, selectedOption],
407+
[showSubmitButton, selectedOption, multiSelect],
395408
);
396409

397410
const ensureChecked = useCallback((optionId: string) => {

0 commit comments

Comments
 (0)