fix(ui): preserve question custom input on refocus

This commit is contained in:
Shantur Rathore
2026-02-07 22:08:38 +00:00
parent 9bd66e7297
commit 4097637169

View File

@@ -132,9 +132,16 @@ export function QuestionToolBlock(props: QuestionToolBlockProps) {
if (!multi) {
// When switching a radio to custom, clear existing selection first.
updateAnswer(questionIndex, [])
toggleOption(questionIndex, value)
return
}
toggleOption(questionIndex, value)
// For multi-select, focusing the input should never toggle an existing custom value off.
// Ensure the current input value is selected; removal is handled by unchecking Custom.
const existing = answers()[questionIndex] ?? []
if (!existing.includes(value)) {
updateAnswer(questionIndex, [...existing, value])
}
}
const clearCustomAnswer = (questionIndex: number, valuesToRemove: string[]) => {