Skip to content

Commit 5947294

Browse files
committed
Fix custom option selection handling
1 parent 2a13dc9 commit 5947294

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

cli/src/components/ask-user/components/accordion-question.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ export const AccordionQuestion: React.FC<AccordionQuestionProps> = ({
121121

122122
// Question number (1-indexed) - only shown when multiple questions
123123
const questionNumber = questionIndex + 1
124+
const isCustomSelected = answer?.isOther ?? false
125+
const customSymbol = isMultiSelect
126+
? isCustomSelected
127+
? SYMBOLS.CHECKBOX_CHECKED
128+
: SYMBOLS.CHECKBOX_UNCHECKED
129+
: isCustomSelected
130+
? SYMBOLS.SELECTED
131+
: SYMBOLS.UNSELECTED
124132

125133
return (
126134
<box style={{ flexDirection: 'column', marginBottom: 1 }}>
@@ -187,7 +195,7 @@ export const AccordionQuestion: React.FC<AccordionQuestionProps> = ({
187195
)
188196
})}
189197

190-
{/* Custom option - text input (always uses radio button style) */}
198+
{/* Custom option - uses checkbox style for multi-select questions */}
191199
<Button
192200
onClick={() => {
193201
if (isMultiSelect) {
@@ -218,7 +226,7 @@ export const AccordionQuestion: React.FC<AccordionQuestionProps> = ({
218226
: undefined,
219227
}}
220228
>
221-
{answer?.isOther ? SYMBOLS.SELECTED : SYMBOLS.UNSELECTED}
229+
{customSymbol}
222230
</text>
223231
<text
224232
style={{

cli/src/components/ask-user/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,15 @@ export const MultipleChoiceForm: React.FC<MultipleChoiceFormProps> = ({
198198
setAnswerForQuestion(questionIndex, (currentAnswer) =>
199199
isOtherOption
200200
? {
201-
...currentAnswer,
201+
// Selecting "Custom" should clear any single-select choice
202+
selectedIndex: undefined,
203+
selectedIndices: undefined,
202204
isOther: true,
203205
otherText: currentAnswer?.otherText || '',
204206
}
205207
: {
206208
selectedIndex: optionIndex,
209+
selectedIndices: undefined,
207210
isOther: false,
208211
},
209212
)

0 commit comments

Comments
 (0)