mirror of
https://github.com/dzeiocom/components.git
synced 2025-04-23 19:32:14 +00:00
fix: strict input not sending infos
Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
This commit is contained in:
parent
f76d0ab344
commit
a6c539918a
@ -320,11 +320,10 @@ export default class Input extends React.Component<Props, States> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof newValue === 'string') {
|
if (typeof newValue === 'string') {
|
||||||
this.setState({value: newValue, displayedValue: newValue, valueUpdate: true})
|
this.onChange(newValue)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.onChange(newValue.value)
|
||||||
this.setState({displayedValue: newValue.display, value: newValue.value, valueUpdate: true})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -382,9 +381,17 @@ export default class Input extends React.Component<Props, States> {
|
|||||||
value = Math.min(max, Math.max(min, val)).toString()
|
value = Math.min(max, Math.max(min, val)).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.strictChoices) {
|
let displayedValue = value
|
||||||
this.setState({ displayedValue: value, valueUpdate: true })
|
|
||||||
return
|
if (this.props.choices) {
|
||||||
|
const item = this.props.choices.find((it) => typeof it === 'string' ? it === value : it.value === value)
|
||||||
|
if (this.props.strictChoices && !item) {
|
||||||
|
this.setState({ displayedValue: displayedValue, valueUpdate: true })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (item && typeof item !== 'string') {
|
||||||
|
displayedValue = item?.display
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.onChange && typeof event === 'object') {
|
if (this.props.onChange && typeof event === 'object') {
|
||||||
@ -394,7 +401,7 @@ export default class Input extends React.Component<Props, States> {
|
|||||||
|
|
||||||
this.props.onValue?.(value)
|
this.props.onValue?.(value)
|
||||||
|
|
||||||
this.setState({ value: value, displayedValue: value, valueUpdate: true })
|
this.setState({ value: value, displayedValue: displayedValue, valueUpdate: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user