Fix not being able to add components when either the screen or layout are selected

This commit is contained in:
Andrew Kingston 2023-08-23 15:19:53 +01:00
parent 4847cafd81
commit 9883157f30
2 changed files with 6 additions and 2 deletions

View File

@ -769,7 +769,7 @@ export const getFrontendStore = () => {
await store.actions.screens.patch(screen => { await store.actions.screens.patch(screen => {
// Find the selected component // Find the selected component
let selectedComponentId = state.selectedComponentId let selectedComponentId = state.selectedComponentId
if (["navigation", "screen"].includes(selectedComponentId)) { if (selectedComponentId.startsWith(`${screen._id}-`)) {
selectedComponentId = screen?.props._id selectedComponentId = screen?.props._id
} }
const currentComponent = findComponent( const currentComponent = findComponent(

View File

@ -1,6 +1,6 @@
<script> <script>
import Panel from "components/design/Panel.svelte" import Panel from "components/design/Panel.svelte"
import { goto, url } from "@roxi/routify" import { goto } from "@roxi/routify"
import { Layout, Search, Icon, Body, notifications } from "@budibase/bbui" import { Layout, Search, Icon, Body, notifications } from "@budibase/bbui"
import structure from "./componentStructure.json" import structure from "./componentStructure.json"
import { store, selectedComponent, selectedScreen } from "builderStore" import { store, selectedComponent, selectedScreen } from "builderStore"
@ -31,6 +31,10 @@
$: orderMap = createComponentOrderMap(componentList) $: orderMap = createComponentOrderMap(componentList)
const getAllowedComponents = (allComponents, screen, component) => { const getAllowedComponents = (allComponents, screen, component) => {
// Default to using the root screen container if no component specified
if (!component) {
component = screen.props
}
const path = findComponentPath(screen?.props, component?._id) const path = findComponentPath(screen?.props, component?._id)
if (!path?.length) { if (!path?.length) {
return [] return []