Skip to content

Commit

Permalink
use Material focus trap, escape tab key navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-CoreyArcher committed Jan 30, 2024
1 parent 117e11e commit ccb9f2a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,12 @@ export class SkyDatepickerCalendarInnerComponent
// const key = this.keys[event.which];
const key = event.key?.toLowerCase();

if (!key || event.shiftKey /* || event.altKey */) {
if (!key || key === 'tab' || event.shiftKey /* || event.altKey */) {
return;
}
if (key !== 'tab') {
event.preventDefault();
event.stopPropagation();
}

event.preventDefault();
event.stopPropagation();

if (key === 'enter' || key === 'space' || key === ' ') {
if (this.isDisabled(this.activeDate)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(calendarModeChange)="onCalendarModeChange($event)"
(selectedDateChange)="onSelectedDateChange($event)"
>
<div tabindex="0" (keydown)="datepicker?.onKeydown($event)">
<div autofocus tabindex="0" (keydown)="datepicker?.onKeydown($event)">
<sky-daypicker
*ngIf="datepicker?.datepickerMode === 'day'"
[customDates]="customDates"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#calendarRef
>
<sky-datepicker-calendar
cdkTrapFocus
[customDates]="customDates"
[isDaypickerWaiting]="isDaypickerWaiting"
[maxDate]="maxDate"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { A11yModule } from '@angular/cdk/a11y';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
Expand Down Expand Up @@ -34,6 +35,7 @@ import { SkyYearPickerComponent } from './yearpicker.component';
SkyDayPickerButtonComponent,
],
imports: [
A11yModule,
CommonModule,
FormsModule,
SkyIconModule,
Expand Down

0 comments on commit ccb9f2a

Please sign in to comment.