2

I'm using the react-datepicker component on my application (https://www.npmjs.com/package/react-datepicker).

I want to close the datepicker calendar only when I click on a certain element that I created on the surrounding of the component, but the default behavior of the datepicker is to close when I click in any place outside him.

How can I do this? I tried this:

<ReactDatePicker selected={startDate}
  startOpen
  shouldCloseOnSelect={false}
  withPortal
  onClickOutside={(e: any)=> { e.preventDefault(); e.stopPropagation(); }} />

But it didn't worked.

Guilherme do Valle
  • 401
  • 1
  • 4
  • 17

0 Answers0