From de13f4ea11cf84b9c34c8f7954dc716fa5a1791f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 20 May 2024 14:50:39 +0100 Subject: [PATCH] Fix multiple issue with colour selection for options --- .../OptionSelectDnD/OptionSelectDnD.svelte | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte b/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte index 22d0fd03a0..09405325a6 100644 --- a/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte +++ b/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte @@ -9,8 +9,8 @@ export let constraints export let optionColors = {} - let options = [] + let options = [] let colorPopovers = [] let anchors = [] @@ -64,9 +64,14 @@ delete optionColors[optionName] } - const openColorPickerPopover = (optionIdx, target) => { - colorPopovers[optionIdx].show() - anchors[optionIdx] = target + const openColorPickerPopover = optionIdx => { + for (let i = 0; i < colorPopovers.length; i++) { + if (i === optionIdx) { + colorPopovers[i].show() + } else { + colorPopovers[i]?.hide() + } + } } onMount(() => { @@ -94,7 +99,7 @@ on:consider={handleDndConsider} on:finalize={handleDndFinalize} > - {#each options as option, idx (option.id)} + {#each options as option, idx (`${option.id}-${idx}`)}
-
+
openColorPickerPopover(idx, e.target)} + >
openColorPickerPopover(idx, e.target)} > -
+
{#each colorsArray as color}
handleColorChange(option.name, color, idx)} @@ -228,6 +232,10 @@ display: flex; } + .color-picker:hover { + cursor: pointer; + } + .circle { height: 20px; width: 20px;