Skip to content

Commit 897dee4

Browse files
crisbetojelbourn
authored andcommitted
fix(material-experimental/mdc-radio): add strong focus indication (#18946)
The MDC-based radio button was missing the strong focus indication that we have in the base radio button. (cherry picked from commit dc80280)
1 parent 29e74eb commit 897dee4

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/material-experimental/mdc-helpers/_mdc-helpers.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ $mat-typography-level-mappings: (
255255
// Render the focus indicator on focus. Defining a pseudo element's
256256
// content will cause it to render.
257257

258-
// For checkboxes and slide toggles, render the focus indicator when we know the hidden input
259-
// is focused (slightly different for each control).
258+
// For checkboxes, radios and slide toggles, render the focus indicator when we know
259+
// the hidden input is focused (slightly different for each control).
260260
.mdc-checkbox__native-control:focus ~ .mat-mdc-focus-indicator::before,
261261
.mat-mdc-slide-toggle-focused .mat-mdc-focus-indicator::before,
262+
.mat-mdc-radio-button.cdk-focused .mat-focus-indicator::before,
262263

263264
// For all other components, render the focus indicator on focus.
264265
.mat-mdc-focus-indicator:focus::before {

src/material-experimental/mdc-radio/radio.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<div class="mdc-radio__inner-circle"></div>
1919
</div>
2020
<div class="mdc-radio__ripple"></div>
21-
<div mat-ripple class="mat-radio-ripple"
21+
<div mat-ripple class="mat-radio-ripple mat-focus-indicator"
2222
[matRippleTrigger]="formField"
2323
[matRippleDisabled]="_isRippleDisabled()"
2424
[matRippleCentered]="true"

src/material-experimental/mdc-radio/radio.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,14 @@ describe('MDC-based MatRadio', () => {
394394
expect(radioNativeElements[2].classList).toContain('mat-warn');
395395
});
396396

397+
it('should have a focus indicator', () => {
398+
const radioRippleNativeElements =
399+
radioNativeElements.map(element => element.querySelector('.mat-radio-ripple')!);
400+
401+
expect(radioRippleNativeElements
402+
.every(element => element.classList.contains('mat-focus-indicator'))).toBe(true);
403+
});
404+
397405
});
398406

399407
describe('group with ngModel', () => {

0 commit comments

Comments
 (0)