Only fire onchange events from form fields when values change to a new valid value
This commit is contained in:
parent
c77abbb372
commit
14ab4c64ce
|
@ -48,8 +48,8 @@
|
|||
}
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
}
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
let fieldApi
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@
|
|||
|
||||
// Skip if the value is the same
|
||||
if (!skipCheck && fieldState.value === value) {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
// Update field state
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
const handleChange = e => {
|
||||
const value = parseValue(e.detail)
|
||||
fieldApi.setValue(value)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(value)
|
||||
if (onChange && changed) {
|
||||
onChange({ value })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
}
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
}
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
)
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@
|
|||
}
|
||||
|
||||
const handleChange = value => {
|
||||
fieldApi.setValue(value)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(value)
|
||||
if (onChange && changed) {
|
||||
onChange({ value })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@
|
|||
}
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
let fieldApi
|
||||
|
||||
const handleChange = e => {
|
||||
fieldApi.setValue(e.detail)
|
||||
if (onChange) {
|
||||
const changed = fieldApi.setValue(e.detail)
|
||||
if (onChange && changed) {
|
||||
onChange({ value: e.detail })
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
|||
{disabled}
|
||||
{validation}
|
||||
{defaultValue}
|
||||
{onChange}
|
||||
type={type === "number" ? "number" : "string"}
|
||||
bind:fieldState
|
||||
bind:fieldApi
|
||||
|
|
Loading…
Reference in New Issue