diff --git a/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte b/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte index 2ad0dc1758..a562862243 100644 --- a/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte +++ b/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte @@ -6,6 +6,7 @@ import TestJobLoader from '$lib/components/TestJobLoader.svelte' import { AppService, type CompletedJob } from '$lib/gen' import { defaultIfEmptyString, emptySchema, sendUserToast } from '$lib/utils' + import { deepEqual } from 'fast-equals' import { getContext, onMount } from 'svelte' import { computeFields } from '../../editor/inlineScriptsPanel/utils' import type { AppInputs, Runnable } from '../../inputType' @@ -38,7 +39,8 @@ jobs, noBackend, errorByComponent, - mode + mode, + stateId } = getContext('AppEditorContext') onMount(() => { @@ -113,13 +115,11 @@ // Inline scripts directly provide the schema if (inlineScript) { const newSchema = inlineScript.schema - const newFields = computeFields(newSchema, defaultUserInput, fields) - if (JSON.stringify(newFields) !== JSON.stringify(fields)) { - setTimeout(() => { - fields = newFields - }, 0) + if (!deepEqual(newFields, fields)) { + fields = newFields + $stateId++ } } } diff --git a/frontend/src/lib/components/apps/editor/AppEditor.svelte b/frontend/src/lib/components/apps/editor/AppEditor.svelte index af4d54ebeb..b572221b3c 100644 --- a/frontend/src/lib/components/apps/editor/AppEditor.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditor.svelte @@ -81,7 +81,8 @@ noBackend: false, errorByComponent, openDebugRun: writable(undefined), - focusedGrid + focusedGrid, + stateId: writable(0) }) let timeout: NodeJS.Timeout | undefined = undefined diff --git a/frontend/src/lib/components/apps/editor/AppPreview.svelte b/frontend/src/lib/components/apps/editor/AppPreview.svelte index 187fe04f75..bc66b13205 100644 --- a/frontend/src/lib/components/apps/editor/AppPreview.svelte +++ b/frontend/src/lib/components/apps/editor/AppPreview.svelte @@ -62,7 +62,8 @@ noBackend, errorByComponent: writable({}), openDebugRun: writable(undefined), - focusedGrid: writable(undefined) + focusedGrid: writable(undefined), + stateId: writable(0) }) let mounted = false diff --git a/frontend/src/lib/components/apps/editor/GridEditor.svelte b/frontend/src/lib/components/apps/editor/GridEditor.svelte index 8e06f594f9..8e747a81b2 100644 --- a/frontend/src/lib/components/apps/editor/GridEditor.svelte +++ b/frontend/src/lib/components/apps/editor/GridEditor.svelte @@ -36,7 +36,7 @@ $app.grid.map((gridItem) => { const disabledGridItem = fct(gridItem) - if (disabledGridItem.data.subGrids) { + if (disabledGridItem?.data?.subGrids) { disabledGridItem.data.subGrids = disabledGridItem.data.subGrids.map( (subgrid: GridItem[]) => subgrid?.map((subgridItem: GridItem) => fct(subgridItem)) ?? [] ) @@ -106,7 +106,7 @@ intervalId = setTimeout(() => { lazyGrid.set($app.grid) intervalId = undefined - }, 100) + }, 500) } } @@ -198,7 +198,7 @@ > removeGridElement(gridComponent.data)} diff --git a/frontend/src/lib/components/apps/editor/SubGridEditor.svelte b/frontend/src/lib/components/apps/editor/SubGridEditor.svelte index fe4628583b..e12797823a 100644 --- a/frontend/src/lib/components/apps/editor/SubGridEditor.svelte +++ b/frontend/src/lib/components/apps/editor/SubGridEditor.svelte @@ -122,7 +122,7 @@ > lock(gridComponent)} diff --git a/frontend/src/lib/components/apps/editor/component/Component.svelte b/frontend/src/lib/components/apps/editor/component/Component.svelte index bf0bd18bae..5062839863 100644 --- a/frontend/src/lib/components/apps/editor/component/Component.svelte +++ b/frontend/src/lib/components/apps/editor/component/Component.svelte @@ -5,7 +5,6 @@ import { twMerge } from 'tailwind-merge' import type { AppEditorContext } from '../../types' import ComponentHeader from '../ComponentHeader.svelte' - import { deepEqual } from 'fast-equals' import { AppBarChart, @@ -40,7 +39,7 @@ import AppAggridTable from '../../components/display/table/AppAggridTable.svelte' import AppDrawer from '../../components/layout/AppDrawer.svelte' - export let pComponent: AppComponent + export let component: AppComponent export let selected: boolean export let locked: boolean = false export let pointerdown: boolean = false @@ -51,10 +50,7 @@ let initializing: boolean | undefined = undefined let componentContainerHeight: number = 0 - let component = JSON.parse(JSON.stringify(pComponent)) - $: if (pComponent && !deepEqual(pComponent, component)) { - component = JSON.parse(JSON.stringify(pComponent)) - } + $: console.log('component', component)
{:else if component.type === 'drawercomponent'} - + {/if}
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte index bbfd8c9076..e27efd533b 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte @@ -31,8 +31,15 @@ export let parent: string | undefined export let noGrid = false - const { app, staticOutputs, runnableComponents, selectedComponent, worldStore, focusedGrid } = - getContext('AppEditorContext') + const { + app, + staticOutputs, + runnableComponents, + selectedComponent, + worldStore, + focusedGrid, + stateId + } = getContext('AppEditorContext') function duplicateElement(id: string) { $dirtyStore = true @@ -110,31 +117,35 @@ /> {/if} - {#if component.componentInput?.type === 'runnable' && Object.keys(component.componentInput.fields ?? {}).length > 0} -
- - - - The runnable inputs of a button component are not settable by the user. They must - be defined statically or connected. - - + {#key $stateId} + {#if component.componentInput?.type === 'runnable'} + {#if Object.keys(component.componentInput.fields ?? {}).length > 0} +
+ + + + The runnable inputs of a button component are not settable by the user. They + must be defined statically or connected. + + - - -
- {/if} + +
+
+ {/if} + {/if} + {/key} {/if} diff --git a/frontend/src/lib/components/apps/types.ts b/frontend/src/lib/components/apps/types.ts index 7a936e7ecd..77525e3a76 100644 --- a/frontend/src/lib/components/apps/types.ts +++ b/frontend/src/lib/components/apps/types.ts @@ -42,14 +42,14 @@ export interface BaseAppComponent extends Partial { configuration: Record< string, GeneralAppInput & - ( - | StaticAppInput - | ConnectedAppInput - | UserAppInput - | RowAppInput - | EvalAppInput - | UploadAppInput - ) + ( + | StaticAppInput + | ConnectedAppInput + | UserAppInput + | RowAppInput + | EvalAppInput + | UploadAppInput + ) > card: boolean | undefined customCss?: ComponentCustomCSS @@ -131,6 +131,7 @@ export type AppEditorContext = { errorByComponent: Writable> openDebugRun: Writable<((componentID: string) => void) | undefined> focusedGrid: Writable + stateId: Writable } export type FocusedGrid = { parentComponentId: string; subGridIndex: number }