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

Datepicker closes after re-rendering component

Open martinvondracek opened this issue 9 years ago • 11 comments

only if you set property closeOnSelect={true}

  1. click into input field to open datepicker
  2. after re-rendering view caused by e.g. setState datepicker closes
  3. you have to click somewhere outside of input field first to re-open datepicker

demo

martinvondracek avatar Dec 22 '16 18:12 martinvondracek

Happens to me aswell.

Confirming

Mistra avatar Dec 26 '16 21:12 Mistra

Datepicker closes if onFocus causes a re-render too, I suppose I'm facing the same issue.

Made a workaround by using Pure Render Mixin and wrapper component but it's not very convenient to use and doesn't help if wrapper component's props change when datepicker is open, but maybe this idea will help someone.

I'd be happy to see this bug fixed though.

AtomicAlienZ avatar Jan 30 '17 21:01 AtomicAlienZ

@simeg guys when are you going to fix this issue? we need it to be fixed soon. thanks

martinvondracek avatar Feb 02 '17 00:02 martinvondracek

@martinvondracek Hey,

If this is something urgent for you I recommend you to create a PR for it. Otherwise I'll look at it when I have the time. Thanks.

simeg avatar Feb 02 '17 09:02 simeg

@martinvondracek, @Mistra, @sunnysingh & @AtomicAlienZ:

This has been fixed in version 2.8.4.

simeg avatar Feb 05 '17 00:02 simeg

Hey guys, sorry but I had to revert the change I made for 2.8.4 (in 2.8.6) due to some other issues. If you're not experiencing any problems with 2.8.4 I recommend you to use that specific version until we can sort everything out. Thanks.

simeg avatar Feb 10 '17 16:02 simeg

Hi there, Faced an issue related to this where clicking the input field for the first time, date picker opened. But when i click the input field again, it just closed. I cross verified it by using onBlur prop and saw that on clicking the input field when the date picker was open, it was going to onBlur method.

For a workaround, i downgraded to version 2.8.4. But there i got another problem where date picker did not close on date selection i.e. closeOnSelect didn't worked.

For that, i used a key prop for the Date Picker component and reset the key every time date is selected. This solved my issue of date picker not closing but date was also getting reset which i handled with the value prop of Date Picker Component by assigning selected value to a state and providing that state to component.

This is just a workaround if someone is stuck. Waiting for the updates to get through this problem. Thanks.

avaneesh-webonise avatar Apr 07 '17 13:04 avaneesh-webonise

Yep, same for me (Chrome). When clicking on the input, picker opens, when clicking again on input in closes. After that, repetitive clicks to input do nothing. The only thing I can do to get it to open again is to click away from the component (blur) and then click the component again.

v2.9.0

bradwestfall avatar Aug 19 '17 02:08 bradwestfall

Same problem here can't get to have both closeOnSelect and re-rendering to work at the same time. on 2.8.4 closeOnSelect does not work, on 2.9.0 updating the state (on Focus for my own purpose) closes the date picker.

jblanche avatar Sep 21 '17 14:09 jblanche

This should be fixed on 2.11.0. It will still close on an update but you can click on input to open again (without clicking outside).

layneanderson avatar Nov 29 '17 21:11 layneanderson

How can I get this to work on my own input component in the renderInput function?

freakaziod210 avatar Jan 03 '18 18:01 freakaziod210