From e90f5d4830e209f74b8b8a59edf731b8549cbf93 Mon Sep 17 00:00:00 2001 From: Akira Sudoh Date: Tue, 10 Dec 2019 05:59:32 +0900 Subject: [PATCH] fix(DatePicker): support focus into a day with min/max (#4793) This change allows user to focus a date into down-arrow key when min/max dates are enabled. When min/max dates are enabled, there can be no selected date in the calendar dropdown or calendar dropdown may not show today, so we need to look for another date to focus on. This change uses the first focusable date. Fixes #4207. --- packages/react/src/components/DatePicker/DatePicker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react/src/components/DatePicker/DatePicker.js b/packages/react/src/components/DatePicker/DatePicker.js index 7b2b50fd8a4d..e288203f821f 100644 --- a/packages/react/src/components/DatePicker/DatePicker.js +++ b/packages/react/src/components/DatePicker/DatePicker.js @@ -412,6 +412,7 @@ export default class DatePicker extends Component { ( cal.selectedDateElem || cal.todayDateElem || + cal.calendarContainer.querySelector('.flatpickr-day[tabindex]') || cal.calendarContainer ).focus(); } @@ -429,6 +430,7 @@ export default class DatePicker extends Component { ( cal.selectedDateElem || cal.todayDateElem || + cal.calendarContainer.querySelector('.flatpickr-day[tabindex]') || cal.calendarContainer ).focus(); }