diff --git a/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte b/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte index 354995ce7a..26d4e39c36 100644 --- a/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte @@ -9,6 +9,7 @@ export let optionColors = {} const flipDurationMs = 150 + const { OptionColours } = Constants let options = [] let colorPopovers = [] @@ -27,7 +28,8 @@ const id = Math.random() options = [...options, { name: newName, id }] constraints.inclusion = [...constraints.inclusion, newName] - optionColors[newName] = Constants.OptionColours[(options.length - 1) % 9] + optionColors[newName] = + OptionColours[(options.length - 1) % OptionColours.length] colorPopovers.push(undefined) anchors.push(undefined) await tick() @@ -64,6 +66,10 @@ } } + const getOptionColor = (name, idx) => { + return optionColors?.[name] || OptionColours[idx % OptionColours.length] + } + onMount(() => { // Initialize anchor arrays on mount, assuming 'options' is already populated colorPopovers = constraints.inclusion.map(() => undefined) @@ -89,6 +95,7 @@ on:finalize={handleDndFinalize} > {#each options as option, idx (`${option.id}-${idx}`)} + {@const color = getOptionColor(option.name, idx)}