From cda114b62cda6ebb4433eab572acf3f7319e8153 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Fri, 12 Aug 2022 08:49:15 +0200 Subject: [PATCH 1/2] Make sure the DOM isn't saved when mounting --- packages/toolpad-app/src/toolpad/DomLoader.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/toolpad-app/src/toolpad/DomLoader.tsx b/packages/toolpad-app/src/toolpad/DomLoader.tsx index 919e9a80f0e..0fb8685db58 100644 --- a/packages/toolpad-app/src/toolpad/DomLoader.tsx +++ b/packages/toolpad-app/src/toolpad/DomLoader.tsx @@ -268,13 +268,13 @@ export default function DomProvider({ appId, children }: DomContextProps) { }); const api = React.useMemo(() => createDomApi(dispatch), []); - const lastSavedDom = React.useRef(null); + const savedDom = React.useRef(state.dom); const handleSave = React.useCallback(() => { - if (!state.dom || lastSavedDom.current === state.dom) { + if (!state.dom || savedDom.current === state.dom) { return; } - lastSavedDom.current = state.dom; + savedDom.current = state.dom; dispatch({ type: 'DOM_SAVING' }); client.mutation From fc82abe359fb2d284d5a3e24b9f465ca7cbfd7c2 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Fri, 12 Aug 2022 08:50:20 +0200 Subject: [PATCH 2/2] don't rename --- packages/toolpad-app/src/toolpad/DomLoader.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/toolpad-app/src/toolpad/DomLoader.tsx b/packages/toolpad-app/src/toolpad/DomLoader.tsx index 0fb8685db58..3d6a051a4ad 100644 --- a/packages/toolpad-app/src/toolpad/DomLoader.tsx +++ b/packages/toolpad-app/src/toolpad/DomLoader.tsx @@ -268,13 +268,13 @@ export default function DomProvider({ appId, children }: DomContextProps) { }); const api = React.useMemo(() => createDomApi(dispatch), []); - const savedDom = React.useRef(state.dom); + const lastSavedDom = React.useRef(state.dom); const handleSave = React.useCallback(() => { - if (!state.dom || savedDom.current === state.dom) { + if (!state.dom || lastSavedDom.current === state.dom) { return; } - savedDom.current = state.dom; + lastSavedDom.current = state.dom; dispatch({ type: 'DOM_SAVING' }); client.mutation