Skip to content

Commit ef7d14f

Browse files
committed
fix(material/core): apply strong focus styles to selected option
Apply strong focus styles to the selected option. Do this by putting the `.mat-mdc-focus-indicator` class on the ripple element. Fix issue where the List styles from MDC override the strong focus style, which causes the strong focus indicator to not be present on selected option (#26801). Align maat-option with list-item's implementation by putting the focus indicator on a child element of the component root, rather than directly on the component root. Does not add aditional DOM nodes.
1 parent 7cd1800 commit ef7d14f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/material/core/option/option.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<!-- See a11y notes inside optgroup.ts for context behind this element. -->
1414
<span class="cdk-visually-hidden" *ngIf="group && group._inert">({{ group.label }})</span>
1515

16-
<div class="mat-mdc-option-ripple" mat-ripple
16+
<div class="mat-mdc-option-ripple mat-mdc-focus-indicator" mat-ripple
1717
[matRippleTrigger]="_getHostElement()"
1818
[matRippleDisabled]="disabled || disableRipple">
1919
</div>

src/material/core/option/option.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@
128128
}
129129

130130
// For options, render the focus indicator when the class .mat-mdc-option-active is present.
131-
.mat-mdc-option-active::before {
131+
.mat-mdc-option-active .mat-mdc-focus-indicator::before {
132132
content: '';
133133
}

src/material/core/option/option.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class _MatOptionBase<T = any> implements FocusableOption, AfterViewChecke
270270
'[attr.aria-disabled]': 'disabled.toString()',
271271
'(click)': '_selectViaInteraction()',
272272
'(keydown)': '_handleKeydown($event)',
273-
'class': 'mat-mdc-option mat-mdc-focus-indicator mdc-list-item',
273+
'class': 'mat-mdc-option mdc-list-item',
274274
},
275275
styleUrls: ['option.css'],
276276
templateUrl: 'option.html',

0 commit comments

Comments
 (0)