Skip to content

Commit

Permalink
Merge pull request #2741 from abiramcodes/bug-datepicker
Browse files Browse the repository at this point in the history
fix: close datepicker on escape key press
  • Loading branch information
zvonimirfras authored Jan 4, 2024
2 parents a845127 + aa609c8 commit 5c29c1f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/datepicker/datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ export class DatePicker implements
// flatpickr calendar using a keyboard.
const addFocusCalendarListener = (element: HTMLInputElement) => {
element.addEventListener("keydown", (event: KeyboardEvent) => {
if (event.key === "Escape") {
this.flatpickrInstance.close();
}
if (event.key === "ArrowDown") {
if (!this.flatpickrInstance.isOpen) {
this.flatpickrInstance.open();
Expand Down

0 comments on commit 5c29c1f

Please sign in to comment.