From 64d4462412d4f5fa0ee49c7bc9e55be4c7f28aad Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 19 Feb 2022 09:10:06 -0800 Subject: [PATCH] fix: Allow removing title via API fix: Empty document title continously autofocuses closes #3108 --- app/components/ContentEditable.tsx | 2 +- server/routes/api/documents.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/components/ContentEditable.tsx b/app/components/ContentEditable.tsx index 86729413a..00635a283 100644 --- a/app/components/ContentEditable.tsx +++ b/app/components/ContentEditable.tsx @@ -73,7 +73,7 @@ const ContentEditable = React.forwardRef( if (autoFocus) { ref.current?.focus(); } - }); + }, [autoFocus, ref]); React.useEffect(() => { if (value !== ref.current?.innerText) { diff --git a/server/routes/api/documents.ts b/server/routes/api/documents.ts index 64d50bf45..872e41ff4 100644 --- a/server/routes/api/documents.ts +++ b/server/routes/api/documents.ts @@ -1009,7 +1009,6 @@ router.post("documents.update", auth(), async (ctx) => { } = ctx.body; const editorVersion = ctx.headers["x-editor-version"] as string | undefined; assertPresent(id, "id is required"); - assertPresent(title || text, "title or text is required"); if (append) { assertPresent(text, "Text is required while appending"); } @@ -1027,7 +1026,7 @@ router.post("documents.update", auth(), async (ctx) => { const previousTitle = document.title; // Update document - if (title) { + if (title !== undefined) { document.title = title; } if (editorVersion) {