question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enter key should close calendar in DatePicker if date is valid.

See original GitHub issue

Pressing the Enter key after typing a date into the DatePicker control selects the date in the calendar dropdown. Instead, it should close the calendar dropdown if the date is valid.

  1. Click or tab to the single DatePicker control here: https://react.carbondesignsystem.com/?path=/story/datepicker--single
  2. Type in a valid date such as 03/03/2024 and press Enter.

Result: note that the date is selected in the calendar drop down. If the date is valid, pressing Enter should just close the calendar dropdown. The only way to close the calendar drop down (that I’ve found) is to press the Down arrow key to move focus to the dropdown itself and then press Enter. This isn’t obvious though.

What package(s) are you using?

  • carbon-components
  • carbon-components-react

Detailed description

Describe in detail the issue you’re having.

Is this issue related to a specific component? DatePicker

What did you expect to happen? What happened instead? What would you like to see changed? I expected that pressing Enter after entering a date manually would cause the dropdown portion of the control to close if the date is valid.

What browser are you working in? Chrome

What version of the Carbon Design System are you using? v7.28.0

What offering/product do you work on? Any pressing ship or release dates we should be aware of? IBM Cognos Analytics 11.2.0

Steps to reproduce the issue

See above.

  • Notes In the previous version of IBM Cognos Analytics where we used our own DatePicker control, pressing enter closed the dropdown, so this is technically a regression for us.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
PaulJThompsoncommented, Mar 5, 2021

I obviously prefer having Enter also close the pop-over calendar as well, since I logged the bug. 😃 The larger issue is that the behaviour ought to be consistent across controls that have a pop-over for folk navigating with a keyboard.

0reactions
tay1orjonescommented, Nov 2, 2022

In looking at this again, it seems what we should aim for here would be:

  • Hitting enter should close the calendar dropdown
  • More importantly, esc should close the calendar
  • This only applies to the single datepicker
Read more comments on GitHub >

github_iconTop Results From Across the Web

JQuery datepicker defaults to todays date when enter key is ...
Basically, what you're looking to do is, when the datePicker widget closes, determine whether the date was chosen by clicking on a date...
Read more >
Date Picker Dialog Example | APG | WAI - W3C
When the dialog is opened, if the input field is empty, or does not contain a valid date, then the current date is...
Read more >
On enter key date validation should happen in KendoReact
I have a date picker in kendo react grid, and when a user enter a invalid date(01/01/0000). and press ENTER key, the data...
Read more >
<input type="date"> - HTML: HyperText Markup Language
Note: The displayed date format will differ from the actual value — the displayed date is formatted based on the locale of the...
Read more >
Date & Time Picker - V-Calendar
To limit user selection to only date components (month, day, year), use mode: 'date' . This is the default prop value, so it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found