Do not re-initialise options if changed (#11964)

* Do not re-initialise options if changed

* Init options onMount
This commit is contained in:
melohagan 2023-10-03 20:55:53 +01:00 committed by GitHub
parent 76dfcf29ba
commit 4df2f622db
1 changed files with 5 additions and 8 deletions

View File

@ -21,14 +21,6 @@
"hsla(240, 90%, 75%, 0.3)",
"hsla(320, 90%, 75%, 0.3)",
]
$: {
if (constraints.inclusion.length) {
options = constraints.inclusion.map(value => ({
name: value,
id: Math.random(),
}))
}
}
const removeInput = idx => {
delete optionColors[options[idx].name]
constraints.inclusion = constraints.inclusion.filter((e, i) => i !== idx)
@ -80,6 +72,11 @@
// Initialize anchor arrays on mount, assuming 'options' is already populated
colorPopovers = constraints.inclusion.map(() => undefined)
anchors = constraints.inclusion.map(() => undefined)
options = constraints.inclusion.map(value => ({
name: value,
id: Math.random(),
}))
})
</script>