From 4baddc544bd65304623d4b3887caf34068a4eecf Mon Sep 17 00:00:00 2001 From: Steven Le Date: Fri, 23 Feb 2024 06:00:44 -0800 Subject: [PATCH] fix: re-load doc card when reference changes --- .changeset/rare-rice-love.md | 5 +++++ .../ui/components/DocEditor/fields/ReferenceField.tsx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/rare-rice-love.md diff --git a/.changeset/rare-rice-love.md b/.changeset/rare-rice-love.md new file mode 100644 index 00000000..325738a4 --- /dev/null +++ b/.changeset/rare-rice-love.md @@ -0,0 +1,5 @@ +--- +'@blinkk/root-cms': patch +--- + +re-load doc card when reference changes diff --git a/packages/root-cms/ui/components/DocEditor/fields/ReferenceField.tsx b/packages/root-cms/ui/components/DocEditor/fields/ReferenceField.tsx index d987cd6b..099230e9 100644 --- a/packages/root-cms/ui/components/DocEditor/fields/ReferenceField.tsx +++ b/packages/root-cms/ui/components/DocEditor/fields/ReferenceField.tsx @@ -90,6 +90,7 @@ ReferenceField.Preview = (props: ReferencePreviewProps) => { const [previewDoc, setPreviewDoc] = useState(null); async function fetchDocData() { + setLoading(true); const docRef = getDraftDocRef(props.id); const doc = await getDoc(docRef); const docData = doc.data(); @@ -106,7 +107,7 @@ ReferenceField.Preview = (props: ReferencePreviewProps) => { return; } fetchDocData(); - }, []); + }, [props.id]); return (