mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Jeremy Elbourn
parent
6824375494
commit
0b8955b792
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user