1

I am working with antd Datepicker and I want custom Datepicker component look like this.

enter image description here

Now, I use prop renderExtraFooter to add custom footer. My input time in footer is other lib (react-datepicker). My problem is here. I can't change, select, focus any input render in extra footer. I want my input time can use (select, change, focus, ...) but I don't know how to do this.

Here is my trying code: https://codesandbox.io/s/antd-custom-antd-12hgbd

I try .blur() antd Datepicker input but still not work.

Any can help me or tell me a lib to custom DatePicker look like picture. Thank for your help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Phát Nguyễn
  • 155
  • 2
  • 16

1 Answers1

2

The only solution is kind of an hack & you will need to handle open & closing of the panel via a state variable.

<DatePicker
  showToday={false}
  open={true}
  renderExtraFooter={() => (
    <div onMouseDown={(e) => e.stopPropagation()}>
     <input />
    </div>
  )}
/>

Edit Extra Footer - Input Focus

If you remove the open={true} prop, the input will focus but the picker will close immediately. You need to control the visibility of the panel with the open property.

A G
  • 21,087
  • 11
  • 87
  • 112