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

Unable To Set Focus After Date Selection

Open vinaysharma14 opened this issue 1 year ago • 1 comments

Describe the bug For example, unable to focus the end date text input after start date has been selected.

To Reproduce Here's a MCVE

const endDateRef = useRef<DatePicker>(null);

<DatePicker
  // ... rest props
  selectsStart
  onSelect={() => endDateRef.current?.setFocus()}
/>

<DatePicker
  // ... rest props
  selectsEnd
  ref={endDateRef}
/>

Expected behavior DatePicker should accept a prop to NOT reset focus back to the input.

Desktop (please complete the following information):

  • OS: macOS Sonoma
  • Browser: Chrome
  • Version: 129.0.6668.59

Additional context Its happening because the start date text input is focused asynchronously after start date has been selected and end date text input has been focused.

https://github.com/Hacker0x01/react-datepicker/blob/9ad0ce00383f769371d670c530541321292e4698/src/index.tsx#L668-L672

https://github.com/Hacker0x01/react-datepicker/blob/9ad0ce00383f769371d670c530541321292e4698/src/index.tsx#L519-L534

vinaysharma14 avatar Sep 27 '24 19:09 vinaysharma14

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar May 10 '25 02:05 github-actions[bot]

This issue was closed because it has been stalled for 10 days with no activity.

github-actions[bot] avatar Aug 24 '25 02:08 github-actions[bot]