How to avoid react date picker calendar to open on tab keypress from previous textbox

2.8k views Asked by At

We have installed react-datepicker component. The default behaviour is that the calendar is getting opened on tab keypress from previous field. How can I avoid this. Please suggest as I am unable to override the default behaviour of this component. I just want the focus to be on this control when tab is pressed.

2

There are 2 answers

1
Meghshyam Sonar On

You can open it manually:

<DatePicker
   ref={(c) => this._calendar = c}
   locale='ru'
    ...
   customInput={<InputField {...this.props} calendar={this._calendar}/>}
/>

And then somewhere

this._calendar.setOpen(bool)
0
Angel Alvarez Pérez On

You can use preventOpenOnFocus property

<DatePicker
  ...
  preventOpenOnFocus={true}
/>