angular / angular/components

Datepicker - When open, pressing Esc key should just close datepicker and stop event propagation

Open
#12,344 3 comments 0 reactions 0 assignees View on GitHub
area: material/datepicker P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Bug, feature request, or proposal:
When a `Datepicker` is open, pressing `Esc` key closes it, which is fine. The issue arises when the parent component is also monitoring `Esc` key.

For example I have a form which contains the `Datepicker` component. I want the form to be closed when the user presses `Esc` key. But if the user has a `Datepicker` open, and presses `Esc` key, it closes the form, whereas it should only close the `Datepicker`.

#### What is the expected behavior?

`Datepicker` should stop propagation of the same event to the parent.

#### What are the steps to reproduce?
Visit https://stackblitz.com/edit/angular-b1wcka

Open datepicker and press `Esc` key to close `datepicker`, this will close the whole form instead of just closing the `datepicker`.

Contributor guide

Open the contributing guide

Research direction

Start at the Datepicker keyboard-event handling and reproduce the behavior using the linked StackBlitz example. Verify that pressing Esc closes the Datepicker without reaching the parent form, while other keyboard behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.