|
|
@ -33,6 +33,7 @@ export default function QuestionText({ |
|
|
const [localValue, setLocalValue] = useState( |
|
|
const [localValue, setLocalValue] = useState( |
|
|
isMuted ? "" : String(value ?? ""), |
|
|
isMuted ? "" : String(value ?? ""), |
|
|
); |
|
|
); |
|
|
|
|
|
const [isReadOnly, setIsReadOnly] = useState(true); |
|
|
const debounceTimerRef = useRef<NodeJS.Timeout | null>(null); |
|
|
const debounceTimerRef = useRef<NodeJS.Timeout | null>(null); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
@ -59,12 +60,17 @@ export default function QuestionText({ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const handleBlur = () => { |
|
|
const handleBlur = () => { |
|
|
|
|
|
setIsReadOnly(true); |
|
|
if (debounceTimerRef.current) { |
|
|
if (debounceTimerRef.current) { |
|
|
clearTimeout(debounceTimerRef.current); |
|
|
clearTimeout(debounceTimerRef.current); |
|
|
} |
|
|
} |
|
|
setAnswerValue(question, localValue); |
|
|
setAnswerValue(question, localValue); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const handleFocus = () => { |
|
|
|
|
|
setIsReadOnly(false); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const stringValue = localValue.trim(); |
|
|
const stringValue = localValue.trim(); |
|
|
const isEmailQuestion = question.type === "email" || question.validation?.format === "email"; |
|
|
const isEmailQuestion = question.type === "email" || question.validation?.format === "email"; |
|
|
|
|
|
|
|
|
@ -101,8 +107,11 @@ export default function QuestionText({ |
|
|
> |
|
|
> |
|
|
<input |
|
|
<input |
|
|
type="text" |
|
|
type="text" |
|
|
inputMode="email" |
|
|
|
|
|
autoComplete="off" |
|
|
|
|
|
|
|
|
name="off_email" |
|
|
|
|
|
readOnly={isReadOnly || disabled || isMuted} |
|
|
|
|
|
onFocus={handleFocus} |
|
|
|
|
|
onTouchStart={handleFocus} |
|
|
|
|
|
autoComplete="one-time-code" |
|
|
autoCorrect="off" |
|
|
autoCorrect="off" |
|
|
autoCapitalize="none" |
|
|
autoCapitalize="none" |
|
|
spellCheck="false" |
|
|
spellCheck="false" |
|
|
@ -147,7 +156,10 @@ export default function QuestionText({ |
|
|
type={isNumericQuestion ? "tel" : "text"} |
|
|
type={isNumericQuestion ? "tel" : "text"} |
|
|
inputMode={isNumericQuestion ? "numeric" : undefined} |
|
|
inputMode={isNumericQuestion ? "numeric" : undefined} |
|
|
pattern={isNumericQuestion ? "[0-9]*" : undefined} |
|
|
pattern={isNumericQuestion ? "[0-9]*" : undefined} |
|
|
autoComplete="off" |
|
|
|
|
|
|
|
|
readOnly={isReadOnly || disabled || isMuted} |
|
|
|
|
|
onFocus={handleFocus} |
|
|
|
|
|
onTouchStart={handleFocus} |
|
|
|
|
|
autoComplete="one-time-code" |
|
|
autoCorrect="off" |
|
|
autoCorrect="off" |
|
|
autoCapitalize="none" |
|
|
autoCapitalize="none" |
|
|
spellCheck="false" |
|
|
spellCheck="false" |
|
|
|