diff --git a/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte b/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte index b7f0ed12d8..bbdf9f55ca 100644 --- a/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte +++ b/packages/frontend-core/src/components/sheet/cells/OptionsCell.svelte @@ -18,8 +18,6 @@ $: options = schema?.constraints?.inclusion || [] $: editable = selected && !readonly $: values = Array.isArray(value) ? value : [value].filter(x => x != null) - $: unselectedOptions = options.filter(x => !values.includes(x)) - $: orderedOptions = values.concat(unselectedOptions) $: { // Close when deselected if (!selected) { @@ -43,7 +41,7 @@ const toggleOption = option => { if (!multi) { - onChange(option) + onChange(option === value ? null : option) close() } else { if (values.includes(option)) { @@ -64,7 +62,7 @@ } else if (e.key === "ArrowUp") { focusedOptionIdx = Math.max(focusedOptionIdx - 1, 0) } else if (e.key === "Enter") { - toggleOption(orderedOptions[focusedOptionIdx]) + toggleOption(options[focusedOptionIdx]) } return true } @@ -100,31 +98,22 @@ {/if} {#if isOpen}