diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 0a5b9f0461..5d0e722650 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -105,7 +105,9 @@ export const getBackendUiStore = () => { state.datasources = state.datasources.filter( existing => existing._id !== datasource._id ) - state.selectedDatasourceId = null + if (datasource._id === state.selectedDatasourceId) { + state.selectedDatasourceId = null + } return state }) }, @@ -233,7 +235,9 @@ export const getBackendUiStore = () => { state.tables = state.tables.filter( existing => existing._id !== table._id ) - state.selectedTable = {} + if (table._id === state.selectedTable._id) { + state.selectedTable = {} + } return state }) }, diff --git a/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte b/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte index c7842001d0..7679f0a9ba 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte @@ -22,9 +22,14 @@ } async function deleteDatasource() { + const wasSelectedSource = $backendUiStore.selectedDatasourceId await backendUiStore.actions.datasources.delete(datasource) notifier.success("Datasource deleted") - $goto('./datasource') + // navigate to first index page if the source you are deleting is selected + console.log('Is the same? ', wasSelectedSource === datasource._id) + if (wasSelectedSource === datasource._id) { + $goto('./datasource') + } hideEditor() } diff --git a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte index 900afe6f86..60886b5be1 100644 --- a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte +++ b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte @@ -1,4 +1,5 @@