diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte index ac87b53db2..c3f3ef71f5 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_layout.svelte @@ -2,7 +2,11 @@ import AppPanel from "./_components/AppPanel.svelte" import * as routify from "@roxi/routify" import { syncURLToState } from "helpers/urlStateSync" - import { screenStore, selectedScreen } from "stores/builder" + import { + screenStore, + selectedScreen, + selectedComponent, + } from "stores/builder" import { onDestroy } from "svelte" import LeftPanel from "./_components/LeftPanel.svelte" diff --git a/packages/builder/src/stores/builder/components.js b/packages/builder/src/stores/builder/components.js index c281c73dfe..21ea255b74 100644 --- a/packages/builder/src/stores/builder/components.js +++ b/packages/builder/src/stores/builder/components.js @@ -574,15 +574,26 @@ export class ComponentStore extends BudiStore { return } - // Determine the next component to select after deletion + // Determine the next component to select, and select it before deletion + // to avoid an intermediate state of no component selection const state = get(this.store) - let nextSelectedComponentId + let nextId if (state.selectedComponentId === component._id) { - nextSelectedComponentId = this.getNext() - if (!nextSelectedComponentId) { - nextSelectedComponentId = this.getPrevious() + nextId = this.getNext() + if (!nextId) { + nextId = this.getPrevious() } } + if (nextId) { + // If this is the nav, select the screen instead + if (nextId.endsWith("-navigation")) { + nextId = nextId.replace("-navigation", "-screen") + } + this.update(state => { + state.selectedComponentId = nextId + return state + }) + } // Patch screen await screenStore.patch(screen => { @@ -601,14 +612,6 @@ export class ComponentStore extends BudiStore { child => child._id !== component._id ) }) - - // Update selected component if required - if (nextSelectedComponentId) { - this.update(state => { - state.selectedComponentId = nextSelectedComponentId - return state - }) - } } copy(component, cut = false, selectParent = true) { diff --git a/packages/client/src/components/preview/GridStylesButton.svelte b/packages/client/src/components/preview/GridStylesButton.svelte index 809efd7971..e168754f3b 100644 --- a/packages/client/src/components/preview/GridStylesButton.svelte +++ b/packages/client/src/components/preview/GridStylesButton.svelte @@ -11,7 +11,6 @@ export let componentId $: currentValue = getGridVarValue(gridStyles, style) - $: console.log(style, currentValue, value) $: active = currentValue === value