Skip to content

Commit 4eee81a

Browse files
authored
fix(datepicker): strong focus indication in calendar always shown (#19304)
1 parent dc9315e commit 4eee81a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/material/core/focus-indicators/_focus-indicators.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
// is present.
7171
.mat-focus-indicator.mat-option.mat-active::before,
7272

73+
// The focus indicator in the calendar is placed on an element inside the cell.
74+
.mat-calendar-body-active .mat-focus-indicator::before,
75+
7376
// For all other components, render the focus indicator on focus.
7477
.mat-focus-indicator:focus::before {
7578
content: '';

src/material/datepicker/calendar-body.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</td>
3030
<td *ngFor="let item of row; let colIndex = index"
3131
role="gridcell"
32-
class="mat-calendar-body-cell mat-focus-indicator"
32+
class="mat-calendar-body-cell"
3333
[ngClass]="item.cssClasses"
3434
[tabindex]="_isActiveCell(rowIndex, colIndex) ? 0 : -1"
3535
[attr.data-mat-row]="rowIndex"
@@ -54,7 +54,7 @@
5454
[style.width]="_cellWidth"
5555
[style.paddingTop]="_cellPadding"
5656
[style.paddingBottom]="_cellPadding">
57-
<div class="mat-calendar-body-cell-content"
57+
<div class="mat-calendar-body-cell-content mat-focus-indicator"
5858
[class.mat-calendar-body-selected]="_isSelected(item)"
5959
[class.mat-calendar-body-today]="todayValue === item.compareValue">
6060
{{item.displayValue}}

src/material/datepicker/calendar-body.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('MatCalendarBody', () => {
107107
});
108108

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

0 commit comments

Comments
 (0)