Skip to content

fix(datepicker): strong focus indication in calendar always shown #19304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/material/core/focus-indicators/_focus-indicators.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
// is present.
.mat-focus-indicator.mat-option.mat-active::before,

// The focus indicator in the calendar is placed on an element inside the cell.
.mat-calendar-body-active .mat-focus-indicator::before,

// For all other components, render the focus indicator on focus.
.mat-focus-indicator:focus::before {
content: '';
Expand Down
4 changes: 2 additions & 2 deletions src/material/datepicker/calendar-body.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</td>
<td *ngFor="let item of row; let colIndex = index"
role="gridcell"
class="mat-calendar-body-cell mat-focus-indicator"
class="mat-calendar-body-cell"
[ngClass]="item.cssClasses"
[tabindex]="_isActiveCell(rowIndex, colIndex) ? 0 : -1"
[attr.data-mat-row]="rowIndex"
Expand All @@ -54,7 +54,7 @@
[style.width]="_cellWidth"
[style.paddingTop]="_cellPadding"
[style.paddingBottom]="_cellPadding">
<div class="mat-calendar-body-cell-content"
<div class="mat-calendar-body-cell-content mat-focus-indicator"
[class.mat-calendar-body-selected]="_isSelected(item)"
[class.mat-calendar-body-today]="todayValue === item.compareValue">
{{item.displayValue}}
Expand Down
2 changes: 1 addition & 1 deletion src/material/datepicker/calendar-body.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('MatCalendarBody', () => {
});

it('should have a focus indicator', () => {
expect(cellEls.every(element => element.classList.contains('mat-focus-indicator')))
expect(cellEls.every(element => !!element.querySelector('.mat-focus-indicator')))
.toBe(true);
});

Expand Down