Add on change action to options field
This commit is contained in:
parent
bd7c009537
commit
02178d3f2b
|
@ -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