Compare commits
1 Commits
v0.13.1-de
...
fix/questi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abe96a7a8b |
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user