Great library! This has been extremely helpful to me! 馃檪
On the Inline Portal version (needed in order to provide a custom input with portal)
You can see this under the Inline Portal version in the example from the documentation
https://reactdatepicker.com/
I tried to handle the key presses myself, but if you add the onKeyDown prop with a function when you set the inline prop, the function passed to onKeyDown will not be called.
Direct link https://reactdatepicker.com/#example-30
Also - can't click the backdrop to escape with inline/portal either.
@mtford90 it's not documented, but you can add an onClickOutside property to the DatePicker component and pass it a toggle function. Basically, do something like the below.
class MyDatePicker extends Component {
state = { isOpen: false };
toggleCalendar = () => this.setState({ isOpen: !this.state.isOpen });
render() {
<input onClick={this.toggleCalendar} />
{this.state.isOpen && (
<DatePicker
inline
withPortal
onClickOutside={this.toggleCalendar}
/>
)}
}
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@mtford90 it's not documented, but you can add an
onClickOutsideproperty to the DatePicker component and pass it a toggle function. Basically, do something like the below.