From de78f1a242fc5d2a93a3f5bb126a37855f9bd8d0 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 23 May 2024 15:20:16 +0100 Subject: [PATCH] Use array.reduce to generate color map --- .../backend/DataTable/modals/OptionsEditor.svelte | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte b/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte index 5eab0bf182..7e02ea422e 100644 --- a/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/OptionsEditor.svelte @@ -28,11 +28,10 @@ const updateConstraints = options => { constraints.inclusion = options.map(option => option.name) - let newColors = {} - options.forEach(option => { - newColors[option.name] = option.color - }) - optionColors = newColors + optionColors = options.reduce( + (colors, option) => ({ ...colors, [option.name]: option.color }), + {} + ) } const getDefaultColor = idx => {