Add on change action to options field
This commit is contained in:
parent
0c83596a86
commit
f70cab8a6c
|
@ -16,6 +16,7 @@
|
|||
export let customOptions
|
||||
export let autocomplete = false
|
||||
export let direction = "vertical"
|
||||
export let onChange
|
||||
|
||||
let fieldState
|
||||
let fieldApi
|
||||
|
@ -30,6 +31,13 @@
|
|||
valueColumn,
|
||||
customOptions
|
||||
)
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Field
|
||||
|
@ -52,7 +60,7 @@
|
|||
error={fieldState.error}
|
||||
{options}
|
||||
{placeholder}
|
||||
on:change={e => fieldApi.setValue(e.detail)}
|
||||
on:change={handleChange}
|
||||
getOptionLabel={flatOptions ? x => x : x => x.label}
|
||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||
{autocomplete}
|
||||
|
@ -66,7 +74,7 @@
|
|||
error={fieldState.error}
|
||||
{options}
|
||||
{direction}
|
||||
on:change={e => fieldApi.setValue(e.detail)}
|
||||
on:change={handleChange}
|
||||
getOptionLabel={flatOptions ? x => x : x => x.label}
|
||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue