Skip to content

Commit 3f8d02c

Browse files
crisbetojosephperrott
authored andcommitted
fix(list): action list missing focus and hover styling (#14147)
Since the action list is interactive, it needs styles when it's hovered and focused.
1 parent 2470a42 commit 3f8d02c

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/lib/list/_list-theme.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
}
2828

2929
.mat-list-option,
30-
.mat-nav-list .mat-list-item {
30+
.mat-nav-list .mat-list-item,
31+
.mat-action-list .mat-list-item {
3132
&:hover, &:focus {
3233
background: mat-color($background, 'hover');
3334
}

src/lib/list/list.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ mat-action-list {
315315
// use something like `@media (hover)`.
316316
@media (hover: none) {
317317
.mat-list-option,
318-
.mat-nav-list .mat-list-item {
318+
.mat-nav-list .mat-list-item,
319+
.mat-action-list .mat-list-item {
319320
&:not(.mat-list-item-disabled):hover {
320321
background: none;
321322
}

src/lib/list/list.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ describe('MatList', () => {
140140
expect(items.length).toBeGreaterThan(0);
141141
});
142142

143+
it('should set the proper class on the action list host', () => {
144+
const fixture = TestBed.createComponent(ActionListWithoutType);
145+
fixture.detectChanges();
146+
147+
const host = fixture.nativeElement.querySelector('mat-action-list');
148+
expect(host.classList).toContain('mat-action-list');
149+
});
150+
143151
it('should enable ripples for action lists by default', () => {
144152
const fixture = TestBed.createComponent(ActionListWithoutType);
145153
fixture.detectChanges();

src/lib/list/list.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export class MatList extends _MatListMixinBase implements CanDisableRipple, OnCh
9494
*/
9595
constructor(private _elementRef?: ElementRef<HTMLElement>) {
9696
super();
97+
98+
if (this._getListType() === 'action-list' && _elementRef) {
99+
_elementRef.nativeElement.classList.add('mat-action-list');
100+
}
97101
}
98102

99103
_getListType(): 'list' | 'action-list' | null {

0 commit comments

Comments
 (0)