diff --git a/frontend/src/lib/components/schema/FlowPropertyEditor.svelte b/frontend/src/lib/components/schema/FlowPropertyEditor.svelte index 921f912366..5211b4e472 100644 --- a/frontend/src/lib/components/schema/FlowPropertyEditor.svelte +++ b/frontend/src/lib/components/schema/FlowPropertyEditor.svelte @@ -16,7 +16,7 @@ import ToggleButton from '../common/toggleButton-v2/ToggleButton.svelte' import Button from '../common/button/Button.svelte' import { Pen, Plus, Trash2 } from 'lucide-svelte' - import Popup from '../common/popup/Popup.svelte' + import Popover from '$lib/components/meltComponents/Popover.svelte' import { deepEqual } from 'fast-equals' export let format: string | undefined = undefined @@ -139,36 +139,36 @@ $: schemaUpdate(schema) let variantName = '' - function createVariant(name: string) { + function createVariant() { if (schema.oneOf) { - if (schema.oneOf.some((obj) => obj.title === name)) { + if (schema.oneOf.some((obj) => obj.title === variantName)) { throw new Error('Variant name already exists') } - const idx = schema.oneOf.findIndex((obj) => obj.title === name) + const idx = schema.oneOf.findIndex((obj) => obj.title === variantName) if (idx === -1) { schema.oneOf = [ ...schema.oneOf, { - title: name, + title: variantName, type: 'object', properties: {} } ] - oneOfSelected = name + oneOfSelected = variantName } variantName = '' } } - function renameVariant(name: string, selected: string) { + function renameVariant(selected: string) { if (schema.oneOf) { - if (schema.oneOf.some((obj) => obj.title === name)) { + if (schema.oneOf.some((obj) => obj.title === variantName)) { throw new Error('Variant name already exists') } const idx = schema.oneOf.findIndex((obj) => obj.title === selected) if (idx !== -1) { - schema.oneOf[idx].title = name - oneOfSelected = name + schema.oneOf[idx].title = variantName + oneOfSelected = variantName } variantName = '' } @@ -176,63 +176,69 @@ let initialObjectSelected = Object.keys(schema?.properties ?? {}).length == 0 ? 'resource' : 'custom-object' + + let disabledVariantName = true + // The purpose of this function is to avoid a re-render of the popover when the variant name changes. + // When the popover content is re-rendered, the popover glitches. + function updateVariantName(value: string) { + variantName = value + disabledVariantName = value.length === 0 + }