fix(datepicker): calendar keyboard controls not working if the user clicks on blank area (#9494)

Fixes the user not being able to use the keyboard controls on a calendar, if they click on one of the blank areas next to a cell. The issue comes from the calendar body not being focusable which ends up returning focus back to the body.
This commit is contained in:
Kristiyan Kostadinov
2018-01-23 16:27:44 +01:00
committed by Jeremy Elbourn
parent 6824375494
commit 0b8955b792
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
</div>
<div class="mat-calendar-content" (keydown)="_handleCalendarBodyKeydown($event)"
[ngSwitch]="_currentView" cdkMonitorSubtreeFocus>
[ngSwitch]="_currentView" cdkMonitorSubtreeFocus tabindex="-1">
<mat-month-view
*ngSwitchCase="'month'"
[activeDate]="_activeDate"
+4
View File
@@ -220,6 +220,10 @@ describe('MatCalendar', () => {
expect(calendarInstance._activeDate).toEqual(new Date(2017, JAN, 31));
});
it('should make the calendar body focusable', () => {
expect(calendarBodyEl.getAttribute('tabindex')).toBe('-1');
});
describe('month view', () => {
it('should decrement date on left arrow press', () => {
dispatchKeyboardEvent(calendarBodyEl, 'keydown', LEFT_ARROW);