Skip to content

Calendar requires two Escape key presses to close #5520

@HugoLiconV

Description

@HugoLiconV

Describe the bug
When using react-datepicker, the Escape key must be pressed twice to close the calendar. The first press removes focus from the input and passes it to the calendar. Only after a second Escape press does the calendar close.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a page with react-datepicker rendered.
  2. Click on the input field to open the calendar.
  3. Press Escape.
  4. Observe that the calendar remains open.
  5. Press Escape again.
  6. Calendar finally closes.

Expected behavior
The calendar should close on the first Escape key press.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacOS 15.3.2
  • Browser: Chrome
  • Version: 133.0.6943.54

Smartphone (please complete the following information):
N/A

Additional context
I tried managing the open state manually and even intercepting the keydown event on the input field with no success. Codesandbox

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions