From 0348894ab839e3b93fe1f1209bf2457dfdb2d8d0 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Tue, 26 Nov 2024 14:04:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20fix=20rerender=20title?= =?UTF-8?q?=20with=20broadcasting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The title was not rerendering on other clients when the title was updated by one client. This commit fixes the issue. We set a min width for the title as well, it will fix the issue with strange behavior when people were double clicking. --- CHANGELOG.md | 1 + .../src/features/docs/doc-header/components/DocTitle.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 309e97db..b6cd9715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to - 🦺(backend) add comma to sub regex #408 - 🐛(editor) collaborative user tag hidden when read only #385 - 🐛(frontend) users have view access when revoked #387 +- 🐛(frontend) fix placeholder editable when double clicks #454 ## [1.7.0] - 2024-10-24 diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx index 0a8a7f90..6c6a9dcf 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx @@ -57,7 +57,7 @@ const DocTitleInput = ({ doc }: DocTitleProps) => { const { broadcast } = useBroadcastStore(); const { mutate: updateDoc } = useUpdateDoc({ - listInvalideQueries: [KEY_DOC, KEY_LIST_DOC], + listInvalideQueries: [KEY_LIST_DOC], onSuccess(data) { if (data.title !== untitledDocument) { toast(t('Document title updated successfully'), VariantType.SUCCESS); @@ -104,6 +104,10 @@ const DocTitleInput = ({ doc }: DocTitleProps) => { } }; + useEffect(() => { + setTitleDisplay(doc.title); + }, [doc.title]); + useEffect(() => { if ((!debounceRef.current && !isUntitled) || !headingText) { return; @@ -129,6 +133,7 @@ const DocTitleInput = ({ doc }: DocTitleProps) => { $radius="4px" $padding={{ horizontal: 'tiny', vertical: '4px' }} $margin="none" + $minWidth="200px" contentEditable={isFirefox() ? 'true' : 'plaintext-only'} onClick={handleOnClick} onBlurCapture={(e) =>