From 651afef833c38add5e47d455c3c0700a5e6c80d8 Mon Sep 17 00:00:00 2001 From: Thomas Dax Date: Thu, 22 Feb 2024 18:00:41 +0100 Subject: [PATCH] Prevent the document editor from losing its state when (re)gaining focus (v5) (#1746) Backport of #1745 --- COM-482 --- .changeset/metal-penguins-tease.md | 8 ++++++++ .../admin/cms-admin/src/pages/pagesPage/PagesPage.tsx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/metal-penguins-tease.md diff --git a/.changeset/metal-penguins-tease.md b/.changeset/metal-penguins-tease.md new file mode 100644 index 0000000000..0fef7fa0bb --- /dev/null +++ b/.changeset/metal-penguins-tease.md @@ -0,0 +1,8 @@ +--- +"@comet/cms-admin": patch +--- + +Prevent the document editor from losing its state when (re)gaining focus + +In v5.6.1 a loading indicator was added to the document editor (in `PagesPage`). +This had an unwanted side effect: Focusing the edit page automatically causes a GraphQL request to check for a newer version of the document. This request also caused the loading indicator to render, thus unmounting the editor (`EditComponent`). Consequently, the local state of the editor was lost. diff --git a/packages/admin/cms-admin/src/pages/pagesPage/PagesPage.tsx b/packages/admin/cms-admin/src/pages/pagesPage/PagesPage.tsx index a50b8fb0ae..31e2ff66b2 100644 --- a/packages/admin/cms-admin/src/pages/pagesPage/PagesPage.tsx +++ b/packages/admin/cms-admin/src/pages/pagesPage/PagesPage.tsx @@ -220,7 +220,7 @@ export function PagesPage({ {(selectedId) => { const page = data?.pages.find((page) => page.id == selectedId); - if (loading) { + if (loading && isInitialLoad.current) { return ; }