Skip to content

Commit

Permalink
Prevent the document editor from losing its state when (re)gaining fo…
Browse files Browse the repository at this point in the history
…cus (v5) (#1746)

Backport of #1745

---

COM-482
  • Loading branch information
thomasdax98 authored Feb 22, 2024
1 parent 62789eb commit 651afef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changeset/metal-penguins-tease.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/admin/cms-admin/src/pages/pagesPage/PagesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function PagesPage({
{(selectedId) => {
const page = data?.pages.find((page) => page.id == selectedId);

if (loading) {
if (loading && isInitialLoad.current) {
return <Loading behavior="fillPageHeight" />;
}

Expand Down

0 comments on commit 651afef

Please sign in to comment.