mirror of
https://github.com/dzeiocom/components.git
synced 2025-04-23 03:12:14 +00:00
fix: Props event not updating internal value
Signed-off-by: Avior <f.bouillon@aptatio.com>
This commit is contained in:
parent
c92dc2d736
commit
cd2304de17
@ -120,7 +120,11 @@ export default class Input extends React.PureComponent<Props, States> {
|
||||
}
|
||||
}
|
||||
|
||||
public async componentDidUpdate(_: Props, prevStates: States) {
|
||||
|
||||
public async componentDidUpdate(prevProps: Props, prevStates: States) {
|
||||
if (prevProps.value !== this.props.value) {
|
||||
this.onChange(this.props.value?.toString() ?? '')
|
||||
}
|
||||
if (prevStates.value !== this.state.value) {
|
||||
if (this.props.onValue) {
|
||||
this.props.onValue(this.state.value ?? '')
|
||||
@ -354,16 +358,16 @@ export default class Input extends React.PureComponent<Props, States> {
|
||||
* handle the change event of the input
|
||||
* @param event the event
|
||||
*/
|
||||
private onChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
private onChange = async (event: React.ChangeEvent<HTMLInputElement>|string) => {
|
||||
// get the input
|
||||
const value = event.currentTarget.value
|
||||
const value = typeof event === 'string' ? event : event.currentTarget.value
|
||||
// console.log("onChange", value)
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.props.onChange) {
|
||||
if (this.props.onChange && typeof event !== 'string') {
|
||||
this.props.onChange(event)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user