Update picker to use null as default placeholder value

This commit is contained in:
Andrew Kingston 2021-02-25 11:34:11 +00:00
parent edf19c8869
commit c3a74c5006
3 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@
// Form API contains functions to control the form
const formApi = {
registerField: (field, defaultValue = undefined, fieldDisabled = false) => {
registerField: (field, defaultValue = null, fieldDisabled = false) => {
if (!field) {
return
}

View File

@ -57,7 +57,7 @@
role="option"
aria-selected="true"
tabindex="0"
on:click={() => onSelectOption(undefined)}>
on:click={() => onSelectOption(null)}>
<span class="spectrum-Menu-itemLabel">{placeholderOption}</span>
<svg
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"

View File

@ -77,7 +77,7 @@
const toggleOption = id => {
if (fieldSchema.relationshipType === "one-to-many") {
fieldApi.setValue([{ _id: id }])
fieldApi.setValue(id ? [{ _id: id }] : [])
} else {
if ($fieldState.value.find(option => option?._id === id)) {
const filtered = $fieldState.value.filter(option => option?._id !== id)