From c2efdd059eb9ad396dfcbb762624ea3198eb364e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Aug 2022 14:47:29 +0100 Subject: [PATCH] Don't clear grid dnd state when loading client library --- .../client/src/components/preview/DNDHandler.svelte | 1 + packages/client/src/index.js | 10 ++++++---- packages/client/src/stores/builder.js | 9 +++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/preview/DNDHandler.svelte b/packages/client/src/components/preview/DNDHandler.svelte index 719f17efe3..7a89b958ae 100644 --- a/packages/client/src/components/preview/DNDHandler.svelte +++ b/packages/client/src/components/preview/DNDHandler.svelte @@ -93,6 +93,7 @@ // Update grid styles if ($builderStore.gridStyles) { builderStore.actions.updateStyles($builderStore.gridStyles) + builderStore.actions.clearGridNextLoad() } // Reset state and styles diff --git a/packages/client/src/index.js b/packages/client/src/index.js index b590ee9b00..3c2f375ac8 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -9,6 +9,10 @@ loadSpectrumIcons() let app const loadBudibase = () => { + if (get(builderStore).clearGridNextLoad) { + builderStore.actions.setDragging(false) + } + // Update builder store with any builder flags builderStore.set({ inBuilder: !!window["##BUDIBASE_IN_BUILDER##"], @@ -21,6 +25,8 @@ const loadBudibase = () => { previewDevice: window["##BUDIBASE_PREVIEW_DEVICE##"], navigation: window["##BUDIBASE_PREVIEW_NAVIGATION##"], hiddenComponentIds: window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"], + gridStyles: get(builderStore).gridStyles, + isDragging: get(builderStore).isDragging, }) // Set app ID - this window flag is set by both the preview and the real @@ -32,10 +38,6 @@ const loadBudibase = () => { const enableDevTools = !get(builderStore).inBuilder && get(appStore).isDevApp devToolsStore.actions.setEnabled(enableDevTools) - if (get(builderStore).gridOffset) { - builderStore.actions.setDragging(false) - } - // Create app if one hasn't been created yet if (!app) { app = new ClientApp({ diff --git a/packages/client/src/stores/builder.js b/packages/client/src/stores/builder.js index 77540b3205..1ab8cdb725 100644 --- a/packages/client/src/stores/builder.js +++ b/packages/client/src/stores/builder.js @@ -19,6 +19,8 @@ const createBuilderStore = () => { isDragging: false, navigation: null, hiddenComponentIds: [], + gridStyles: null, + clearGridNextLoad: false, // Legacy - allow the builder to specify a layout layout: null, @@ -74,6 +76,7 @@ const createBuilderStore = () => { ...state, isDragging: dragging, gridStyles: null, + clearGridNextLoad: false, })) }, setEditMode: enabled => { @@ -97,6 +100,12 @@ const createBuilderStore = () => { return state }) }, + clearGridNextLoad: () => { + store.update(state => { + state.clearGridNextLoad = true + return state + }) + }, } return { ...store,