React-datepicker: Inline Portal won't close on 'escape'

Created on 13 Aug 2018  路  4Comments  路  Source: Hacker0x01/react-datepicker

Great library! This has been extremely helpful to me! 馃檪

Expected behavior

On the Inline Portal version (needed in order to provide a custom input with portal)

  • hit 'escape' => portal should close
  • hit arrow keys => date selected should change

Actual behavior

  • hit 'escape' => nothing happens
  • hit arrow keys => nothing happens

Steps to reproduce

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.

wontfix

Most helpful comment

@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}
      />
    )}
  }
}

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arturictus picture arturictus  路  3Comments

formigone picture formigone  路  3Comments

ahribori picture ahribori  路  3Comments

evolve2k picture evolve2k  路  3Comments

lclemence picture lclemence  路  3Comments