Fix add component FAB not working when screen or navigation are selected

This commit is contained in:
Andrew Kingston 2023-08-23 15:04:18 +01:00
parent 899a1dd754
commit 08d2074515
2 changed files with 6 additions and 11 deletions

View File

@ -1,12 +1,7 @@
<script> <script>
import { get } from "svelte/store" import { get } from "svelte/store"
import { onMount, onDestroy } from "svelte" import { onMount, onDestroy } from "svelte"
import { import { store, selectedScreen, currentAsset } from "builderStore"
store,
selectedComponent,
selectedScreen,
currentAsset,
} from "builderStore"
import ConfirmDialog from "components/common/ConfirmDialog.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import { import {
ProgressCircle, ProgressCircle,
@ -70,7 +65,7 @@
$: refreshContent(json) $: refreshContent(json)
// Determine if the add component menu is active // Determine if the add component menu is active
$: isAddingComponent = $isActive(`./${$selectedComponent?._id}/new`) $: isAddingComponent = $isActive(`./${selectedComponentId}/new`)
// Register handler to send custom to the preview // Register handler to send custom to the preview
$: sendPreviewEvent = (name, payload) => { $: sendPreviewEvent = (name, payload) => {
@ -212,10 +207,10 @@
} }
const toggleAddComponent = () => { const toggleAddComponent = () => {
if (isAddingComponent) { if ($isActive(`./${selectedComponentId}/new`)) {
$goto(`./${$selectedComponent?._id}`) $goto(`./${selectedComponentId}`)
} else { } else {
$goto(`./${$selectedComponent?._id}/new`) $goto(`./${selectedComponentId}/new`)
} }
} }

View File

@ -15,7 +15,7 @@
const toNewComponentRoute = () => { const toNewComponentRoute = () => {
if ($isActive(`./${$store.selectedComponentId}/new`)) { if ($isActive(`./${$store.selectedComponentId}/new`)) {
return $goto(`./${$store.selectedComponentId}`)
} else { } else {
$goto(`./${$store.selectedComponentId}/new`) $goto(`./${$store.selectedComponentId}/new`)
} }