diff --git a/src/features/tech-log/presentation/studio/components/home-focus-editor.tsx b/src/features/tech-log/presentation/studio/components/home-focus-editor.tsx index 107206c..41a16e5 100644 --- a/src/features/tech-log/presentation/studio/components/home-focus-editor.tsx +++ b/src/features/tech-log/presentation/studio/components/home-focus-editor.tsx @@ -39,6 +39,19 @@ const HOME_FOCUS_SCHEMA = z.object({ decisionId: z.string(), }); +/** + * One object for the life of the module. useAppForm's `reset` depends on + * `defaultValues`, and the effect below resets the form when `reset` changes: + * a literal here made a new `reset` every render, so as soon as a home focus + * loaded the editor reset itself, re-rendered and reset again without end. + * release-editor.tsx keeps its defaults the same way (EMPTY_RELEASE_DRAFT). + */ +const EMPTY_HOME_FOCUS = Object.freeze({ + projectId: "", + questionId: "", + decisionId: "", +}); + export function HomeFocusEditor() { const copy = useTechLogCopy(); const { setRequestAnnouncement } = useStudio(); @@ -51,11 +64,7 @@ export function HomeFocusEditor() { const form = useAppForm({ schema: HOME_FOCUS_SCHEMA, - defaultValues: { - projectId: "", - questionId: "", - decisionId: "", - }, + defaultValues: EMPTY_HOME_FOCUS, allowedServerFields: ["projectId", "questionId", "decisionId"] as const, mapToCommand(values) { return {