Compare commits

...

1 Commits

Author SHA1 Message Date
Shantur Rathore
abe96a7a8b fix(ui): keep submit disabled for empty custom answer 2026-01-28 15:32:12 +00:00

View File

@@ -112,7 +112,6 @@ export function QuestionToolBlock(props: QuestionToolBlockProps) {
if (!props.active()) return if (!props.active()) return
const rawValue = input?.value ?? "" const rawValue = input?.value ?? ""
const value = rawValue const value = rawValue
if (value.trim().length === 0) return
const info = questions()[questionIndex] const info = questions()[questionIndex]
const multi = info?.multiple === true const multi = info?.multiple === true
@@ -121,6 +120,19 @@ export function QuestionToolBlock(props: QuestionToolBlockProps) {
updateAnswer(questionIndex, []) updateAnswer(questionIndex, [])
} }
// If the custom field is empty, treat it as unanswered.
// This prevents submitting a previously selected option when the user
// has explicitly switched focus to the custom input.
if (value.trim().length === 0) return
if (multi) {
const existing = answers()[questionIndex] ?? []
if (!existing.includes(value)) {
updateAnswer(questionIndex, [...existing, value])
}
return
}
toggleOption(questionIndex, value) toggleOption(questionIndex, value)
} }
@@ -281,6 +293,9 @@ export function QuestionToolBlock(props: QuestionToolBlockProps) {
onInput={(e) => handleCustomTyping(i(), e.currentTarget)} onInput={(e) => handleCustomTyping(i(), e.currentTarget)}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === "Enter" && !e.isComposing) { if (e.key === "Enter" && !e.isComposing) {
// Don't submit if the custom field is empty (common when switching to it).
if (e.currentTarget.value.trim().length === 0) return
e.preventDefault()
if (!submitDisabled()) { if (!submitDisabled()) {
props.onSubmit() props.onSubmit()
} }