diff --git a/src/material/core/option/option.html b/src/material/core/option/option.html index e6e94c70c81f..aff571f282f3 100644 --- a/src/material/core/option/option.html +++ b/src/material/core/option/option.html @@ -13,7 +13,7 @@ ({{ group.label }}) -
diff --git a/src/material/core/option/option.scss b/src/material/core/option/option.scss index a5f4a7a3ed19..be9560e5a677 100644 --- a/src/material/core/option/option.scss +++ b/src/material/core/option/option.scss @@ -128,6 +128,6 @@ } // For options, render the focus indicator when the class .mat-mdc-option-active is present. -.mat-mdc-option-active::before { +.mat-mdc-option-active .mat-mdc-focus-indicator::before { content: ''; } diff --git a/src/material/core/option/option.spec.ts b/src/material/core/option/option.spec.ts index d88974fc51f2..64fdaedaaf5d 100644 --- a/src/material/core/option/option.spec.ts +++ b/src/material/core/option/option.spec.ts @@ -201,7 +201,12 @@ describe('MatOption component', () => { const fixture = TestBed.createComponent(BasicOption); const optionNativeElement = fixture.debugElement.query(By.directive(MatOption))!.nativeElement; - expect(optionNativeElement.classList.contains('mat-mdc-focus-indicator')).toBe(true); + expect(optionNativeElement.parentElement.querySelector('.mat-mdc-focus-indicator')) + .withContext( + 'expected to find a focus indicator on ' + + "either the mat-option element or one of it's children", + ) + .not.toBeNull(); }); describe('inside inert group', () => { diff --git a/src/material/core/option/option.ts b/src/material/core/option/option.ts index bc159afce814..d9a455f9bc26 100644 --- a/src/material/core/option/option.ts +++ b/src/material/core/option/option.ts @@ -270,7 +270,7 @@ export class _MatOptionBase implements FocusableOption, AfterViewChecke '[attr.aria-disabled]': 'disabled.toString()', '(click)': '_selectViaInteraction()', '(keydown)': '_handleKeydown($event)', - 'class': 'mat-mdc-option mat-mdc-focus-indicator mdc-list-item', + 'class': 'mat-mdc-option mdc-list-item', }, styleUrls: ['option.css'], templateUrl: 'option.html',