Add on change action to attachment field

This commit is contained in:
Andrew Kingston 2022-04-14 09:46:24 +01:00
parent 04b299750d
commit 9b56dcfdfe
1 changed files with 9 additions and 3 deletions

View File

@ -8,6 +8,7 @@
export let disabled = false export let disabled = false
export let validation export let validation
export let extensions export let extensions
export let onChange
let fieldState let fieldState
let fieldApi let fieldApi
@ -38,6 +39,13 @@
return [] return []
} }
} }
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script> </script>
<Field <Field
@ -55,9 +63,7 @@
value={fieldState.value} value={fieldState.value}
disabled={fieldState.disabled} disabled={fieldState.disabled}
error={fieldState.error} error={fieldState.error}
on:change={e => { on:change={handleChange}
fieldApi.setValue(e.detail)
}}
{processFiles} {processFiles}
{handleFileTooLarge} {handleFileTooLarge}
{extensions} {extensions}