Skip to content

Commit f405cb6

Browse files
authored
fix(expansion): add strong focus indication (#18552)
Since the color contrast on the expansion panel focus state isn't great, it's a good candidate to have strong focus indication.
1 parent 5b23084 commit f405cb6

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/material/expansion/expansion-panel-header.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
align-items: center;
55
padding: 0 24px;
66
border-radius: inherit;
7+
position: relative; // Necessary for the strong focus indication.
78

89
&:focus,
910
&:hover {

src/material/expansion/expansion-panel-header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {MatAccordionTogglePosition} from './accordion-base';
4848
matExpansionAnimations.expansionHeaderHeight
4949
],
5050
host: {
51-
'class': 'mat-expansion-panel-header',
51+
'class': 'mat-expansion-panel-header mat-focus-indicator',
5252
'role': 'button',
5353
'[attr.id]': 'panel._headerId',
5454
'[attr.tabindex]': 'disabled ? -1 : 0',

src/material/expansion/expansion-panel.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
transition: margin 225ms $mat-fast-out-slow-in-timing-function,
1414
mat-elevation-transition-property-value();
1515

16+
// Required so that the `box-shadow` works after we add `position: relative` to the header.
17+
position: relative;
18+
1619
.mat-accordion & {
1720
&:not(.mat-expanded), &:not(.mat-expansion-panel-spacing) {
1821
border-radius: 0;

src/material/expansion/expansion.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ describe('MatExpansionPanel', () => {
4949
expect(headerEl.classList).toContain('mat-expanded');
5050
}));
5151

52+
it('should add strong focus indication', fakeAsync(() => {
53+
const fixture = TestBed.createComponent(PanelWithContent);
54+
fixture.detectChanges();
55+
56+
expect(fixture.nativeElement.querySelector('.mat-expansion-panel-header').classList)
57+
.toContain('mat-focus-indicator');
58+
}));
59+
5260
it('should be able to render panel content lazily', fakeAsync(() => {
5361
const fixture = TestBed.createComponent(LazyPanelWithContent);
5462
const content = fixture.debugElement.query(

0 commit comments

Comments
 (0)