Skip to content

Commit 05d105c

Browse files
appflowyclaude
andauthored
fix: prevent title input remount on outline update in view modal (#331)
The loadPageDoc effect depended on the `resolvedView` object reference, so every title edit that propagated through the outline produced a fresh view object, re-fired the effect, and called setDoc(undefined) — which unmounted the editor mid-keystroke and reset the title to the server-side value on remount. Depend on a boolean derived from resolvedView instead, so the effect only fires on the genuine "metadata absent → present" transition. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ade09b4 commit 05d105c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/components/app/ViewModal.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,17 @@ function ViewModal({ viewId, open, onClose }: { viewId?: string; open: boolean;
163163
// and the correct layout is known for the page-view API call.
164164
const resolvedView = effectiveOutlineView || fallbackMeta;
165165

166+
// Gate on metadata availability via a boolean so outline updates (e.g. a
167+
// title edit propagating through the outline tree) don't churn the dep
168+
// array and re-trigger loadPageDoc — which would setDoc(undefined) and
169+
// remount the editor mid-keystroke.
170+
const hasResolvedView = !!resolvedView;
171+
166172
useEffect(() => {
167-
if (open && effectiveViewId && resolvedView) {
173+
if (open && effectiveViewId && hasResolvedView) {
168174
void loadPageDoc(effectiveViewId);
169175
}
170-
}, [open, effectiveViewId, loadPageDoc, resolvedView]);
176+
}, [open, effectiveViewId, loadPageDoc, hasResolvedView]);
171177

172178
const layout = resolvedView?.layout ?? ViewLayout.Document;
173179

0 commit comments

Comments
 (0)