react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Clear date inputs dosn't fire onChange props method!

Open kleviscipi opened this issue 5 years ago • 3 comments

Using RangeDatePicker in combination with props clear, the event fire doesn't call the method onChange . I am using this library and it is great but is very necessary for me to have that feature. A props *onClear should be great, which is called when handleInputClear (inside the RangeDatePicker) is fired

kleviscipi avatar Apr 11 '20 16:04 kleviscipi

@kleviscipi did you find a solution for that ?

SarahAlAshwal avatar Aug 20 '21 16:08 SarahAlAshwal

This is an open issue still we are facing. Did any update happen on this?

manish-sh14 avatar Mar 02 '22 09:03 manish-sh14

@manish-sh14 @SarahAlAshwal

I'm using the prop inputComponent to generate an element (input) by my self with default date values and i'm not using the clear features.

Something like this:

            <DatePicker 
                onChange= {this.onChange}
                locale="it"
                portal={this.props.portal||false}
                icon={this.getIcon()}
                placeholder={this.props.placeholder||""}
                inputComponent={(props)=>{
                    let newProps = props

                    if(!this.getValue()){
                            newProps.value = ""
                    }

                    if( this.state.value && this.getValue() ){
                        newProps.value = this.state.value
                    }
                    return <input type="text" className="form-control" {...newProps} />
                }}
                initialDate={this.props.initialDate}
            />

kleviscipi avatar Mar 02 '22 10:03 kleviscipi