React-datepicker: Datepicker doesn't exit on mobile when selecting date and time.

Created on 23 Jan 2018  路  6Comments  路  Source: Hacker0x01/react-datepicker

Expected behavior

When I select a date and then a time, the Datepicker should close

Actual behavior

When I select a date and then a time, the Datepicker stays open

Steps to reproduce

<DatePicker
      selected={props.startDate}
      onChange={props.changeStartDate}
      showTimeSelect
      timeIntervals={30}
      dateFormat="MM/DD/YY, hh:mm a"
      todayButton="Today"
      minDate={moment()}
      readOnly
       />

I have the latest version. I'm not sure why this is happening.

wontfix

Most helpful comment

I find that adding 'preventOpenOnFocus' to props will solve this problem
<DatePicker selected={props.startDate} onChange={props.changeStartDate} showTimeSelect timeIntervals={30} dateFormat="MM/DD/YY, hh:mm a" todayButton="Today" minDate={moment()} readOnly preventOpenOnFocus />

All 6 comments

Same here!

I'm seeing this on dekstop as well.

I experience this problem using mobile Chrome browser and also desktop Chrome with device mode on. Couldn't reproduce this problem at Firefox

I find that adding 'preventOpenOnFocus' to props will solve this problem
<DatePicker selected={props.startDate} onChange={props.changeStartDate} showTimeSelect timeIntervals={30} dateFormat="MM/DD/YY, hh:mm a" todayButton="Today" minDate={moment()} readOnly preventOpenOnFocus />

I have resolved this issue and already created PR #1400

Use of preventOpenOnFocus is not used that much if my requirement is related to the focus event like in the form after every field user generally used the tab to move next.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings