Don't clear grid dnd state when loading client library

This commit is contained in:
Andrew Kingston 2022-08-26 14:47:29 +01:00
parent 16c9c6c0dc
commit c2efdd059e
3 changed files with 16 additions and 4 deletions

View File

@ -93,6 +93,7 @@
// Update grid styles // Update grid styles
if ($builderStore.gridStyles) { if ($builderStore.gridStyles) {
builderStore.actions.updateStyles($builderStore.gridStyles) builderStore.actions.updateStyles($builderStore.gridStyles)
builderStore.actions.clearGridNextLoad()
} }
// Reset state and styles // Reset state and styles

View File

@ -9,6 +9,10 @@ loadSpectrumIcons()
let app let app
const loadBudibase = () => { const loadBudibase = () => {
if (get(builderStore).clearGridNextLoad) {
builderStore.actions.setDragging(false)
}
// Update builder store with any builder flags // Update builder store with any builder flags
builderStore.set({ builderStore.set({
inBuilder: !!window["##BUDIBASE_IN_BUILDER##"], inBuilder: !!window["##BUDIBASE_IN_BUILDER##"],
@ -21,6 +25,8 @@ const loadBudibase = () => {
previewDevice: window["##BUDIBASE_PREVIEW_DEVICE##"], previewDevice: window["##BUDIBASE_PREVIEW_DEVICE##"],
navigation: window["##BUDIBASE_PREVIEW_NAVIGATION##"], navigation: window["##BUDIBASE_PREVIEW_NAVIGATION##"],
hiddenComponentIds: window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"], 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 // 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 const enableDevTools = !get(builderStore).inBuilder && get(appStore).isDevApp
devToolsStore.actions.setEnabled(enableDevTools) devToolsStore.actions.setEnabled(enableDevTools)
if (get(builderStore).gridOffset) {
builderStore.actions.setDragging(false)
}
// Create app if one hasn't been created yet // Create app if one hasn't been created yet
if (!app) { if (!app) {
app = new ClientApp({ app = new ClientApp({

View File

@ -19,6 +19,8 @@ const createBuilderStore = () => {
isDragging: false, isDragging: false,
navigation: null, navigation: null,
hiddenComponentIds: [], hiddenComponentIds: [],
gridStyles: null,
clearGridNextLoad: false,
// Legacy - allow the builder to specify a layout // Legacy - allow the builder to specify a layout
layout: null, layout: null,
@ -74,6 +76,7 @@ const createBuilderStore = () => {
...state, ...state,
isDragging: dragging, isDragging: dragging,
gridStyles: null, gridStyles: null,
clearGridNextLoad: false,
})) }))
}, },
setEditMode: enabled => { setEditMode: enabled => {
@ -97,6 +100,12 @@ const createBuilderStore = () => {
return state return state
}) })
}, },
clearGridNextLoad: () => {
store.update(state => {
state.clearGridNextLoad = true
return state
})
},
} }
return { return {
...store, ...store,