Add on change action to long form field

This commit is contained in:
Andrew Kingston 2022-04-14 09:49:13 +01:00
parent b886fe95c2
commit bd313c7204
1 changed files with 10 additions and 2 deletions

View File

@ -11,6 +11,7 @@
export let validation
export let defaultValue = ""
export let format = "auto"
export let onChange
let fieldState
let fieldApi
@ -44,6 +45,13 @@
},
})
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -61,7 +69,7 @@
{#if useRichText}
<CoreRichTextField
value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}
@ -78,7 +86,7 @@
{:else}
<CoreTextArea
value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}