t0gre / react-datepicker

An easily internationalizable, accessible, mobile-friendly datepicker library for the web, build with styled-components.
https://react-datepicker.netlify.com/
MIT License
331 stars 54 forks source link

Prevent to hide datepicker when clicking anywhere, but close it when clicking close button #154

Open DanielBSeeTrue opened 9 months ago

DanielBSeeTrue commented 9 months ago

I want to be able to close when clicking the X close button but not to close when clicking anywhere I tried implementing that if onFocusChange , focusinput is null, I will keep it open by focusing on start date but the button close also produced null

my code:

<DateRangeInput
        onDatesChange={(data) => {
          setState(data);
        }}
        onFocusChange={(focusedInput) => {
          console.log(focusedInput); 
          if (focusedInput === null) {
            setState((prev) => ({ ...prev, focusedInput: START_DATE }));
          } else {
            setState((prev) => ({ ...prev, focusedInput }))
          }
        }
        }
        startDate={props.startDate}
        endDate={props.endDate}
        focusedInput={state.focusedInput}
        displayFormat="dd/MM/yyyy"
      />