Add on change action to relationship field

This commit is contained in:
Andrew Kingston 2022-04-14 10:01:14 +01:00
parent f70cab8a6c
commit 67f94e0cae
1 changed files with 10 additions and 2 deletions

View File

@ -13,6 +13,7 @@
export let validation
export let autocomplete = false
export let defaultValue
export let onChange
let fieldState
let fieldApi
@ -62,11 +63,11 @@
}
const singleHandler = e => {
fieldApi.setValue(e.detail == null ? [] : [e.detail])
handleChange(e.detail == null ? [] : [e.detail])
}
const multiHandler = e => {
fieldApi.setValue(e.detail)
handleChange(e.detail)
}
const expand = values => {
@ -78,6 +79,13 @@
}
return values.split(",").map(value => value.trim())
}
const handleChange = value => {
fieldApi.setValue(value)
if (onChange) {
onChange({ value })
}
}
</script>
<Field