diff --git a/src/components/Componentes/question-phone.test.tsx b/src/components/Componentes/question-phone.test.tsx index 08cacc0..c36b282 100644 --- a/src/components/Componentes/question-phone.test.tsx +++ b/src/components/Componentes/question-phone.test.tsx @@ -27,14 +27,14 @@ vi.mock("./question-answer-storage", () => ({ })); describe("QuestionPhone Component", () => { - const mockQuestion: QuestionField = { + const mockQuestion = { id: "personal_contact_number", title: "شماره تماس شخصی", type: "phone", extras: { placeHolder: "+98 9123456789", }, - }; + } as QuestionField; it("renders phone input and opens sheet on country code click", async () => { render(); diff --git a/src/components/Componentes/question-text.tsx b/src/components/Componentes/question-text.tsx index b5133cf..1f0cdbb 100644 --- a/src/components/Componentes/question-text.tsx +++ b/src/components/Componentes/question-text.tsx @@ -33,6 +33,7 @@ export default function QuestionText({ const [localValue, setLocalValue] = useState( isMuted ? "" : String(value ?? ""), ); + const [isReadOnly, setIsReadOnly] = useState(true); const debounceTimerRef = useRef(null); useEffect(() => { @@ -59,12 +60,17 @@ export default function QuestionText({ }; const handleBlur = () => { + setIsReadOnly(true); if (debounceTimerRef.current) { clearTimeout(debounceTimerRef.current); } setAnswerValue(question, localValue); }; + const handleFocus = () => { + setIsReadOnly(false); + }; + const stringValue = localValue.trim(); const isEmailQuestion = question.type === "email" || question.validation?.format === "email"; @@ -101,8 +107,11 @@ export default function QuestionText({ >