From a4ee3d25f070ef5d2cb844298e441b5b59eddc8e Mon Sep 17 00:00:00 2001 From: Pavel Eliseev Date: Sun, 4 Oct 2026 16:14:37 +0300 Subject: [PATCH] fix(web): allow returning home from questionnaires Keep the shared dialog and submitted answers while leaving the focus screen. Remove the history trap and wire the text-step home action. Refs #85 --- web/src/content/ru.ts | 1 + web/src/screens/Flow.tsx | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/src/content/ru.ts b/web/src/content/ru.ts index 37e1b28..1810915 100644 --- a/web/src/content/ru.ts +++ b/web/src/content/ru.ts @@ -204,6 +204,7 @@ export const ru = { toIntake: "Пройти первичный опрос", }, flow: { + home: "На главный экран", question: (n: number, total: number) => `Вопрос ${n} из ${total}`, period: "За последний месяц", textPlaceholder: "Напишите несколько слов", diff --git a/web/src/screens/Flow.tsx b/web/src/screens/Flow.tsx index 50d15fb..8613b56 100644 --- a/web/src/screens/Flow.tsx +++ b/web/src/screens/Flow.tsx @@ -265,7 +265,7 @@ function FreeText({ {skip.label} ) : ( - )} @@ -362,6 +362,7 @@ function SurveyAct({ press, say, onPause, + onHome, }: { step: Survey; stepKey: string; @@ -369,6 +370,7 @@ function SurveyAct({ press: (b: DialogButton) => void; say: (text: string) => void; onPause: (b: DialogButton) => void; + onHome: () => void; }) { let answer: ReactNode; switch (step.input) { @@ -381,7 +383,7 @@ function SurveyAct({ break; case "text": answer = ( - undefined} /> + ); break; default: @@ -522,17 +524,6 @@ export function Flow() { navigate("/today", { replace: true }); }, [step, stepKey, navigate, toast]); - // Questionnaire: answers are saved on the server per question, and there is no going back to change one. - // The browser «back» is absorbed by a duplicate history entry of this same screen. - const testing = step?.kind === "survey" || step?.kind === "choice" || step?.kind === "consent"; - useEffect(() => { - if (!testing) return; - window.history.pushState(null, "", window.location.href); - const stay = () => window.history.pushState(null, "", window.location.href); - window.addEventListener("popstate", stay); - return () => window.removeEventListener("popstate", stay); - }, [testing]); - const press = (b: DialogButton) => void dialog.send({ type: "button", button: b.data }, b.label); // «Продолжить позже»: answers are already saved on the server — pause and go straight home, no confirmation. const pause = (b: DialogButton) => @@ -588,7 +579,7 @@ export function Flow() { ) : item ? ( ) : null; - const top = {progress}; + const top = progress ? {progress} : null; // Phone: one column. Desktop: question and context on the left, answers and actions on the right. let lead: ReactNode; let act: ReactNode; @@ -702,7 +693,7 @@ export function Flow() { break; case "survey": lead = ; - act = ; + act = ; break; case "choice": lead = ; @@ -725,6 +716,14 @@ export function Flow() { return ( + {content} );