From 2a39d9f9d677a3efafccc6bd3d7b33e8d7bd901b Mon Sep 17 00:00:00 2001 From: Elizabeth Mitchell Date: Tue, 30 May 2023 12:01:25 -0700 Subject: [PATCH] fix(radio): checked styles not displaying Fixes #4347 PiperOrigin-RevId: 536469791 --- radio/lib/_radio.scss | 14 +++++++------- radio/lib/radio.ts | 44 +++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/radio/lib/_radio.scss b/radio/lib/_radio.scss index 8bd26d323f2..65785377956 100644 --- a/radio/lib/_radio.scss +++ b/radio/lib/_radio.scss @@ -62,7 +62,7 @@ $_md-sys-motion: tokens.md-sys-motion-values(); -webkit-tap-highlight-color: transparent; } - :host([checked]) { + .checked { @include ripple.theme( ( hover-color: var(--_selected-hover-state-layer-color), @@ -108,11 +108,11 @@ $_md-sys-motion: tokens.md-sys-motion-values(); transition: opacity 50ms linear; } - :host([checked]) .icon { + .checked .icon { fill: var(--_selected-icon-color); } - :host([checked]) .inner.circle { + .checked .inner.circle { animation: inner-circle-grow 300ms map.get($_md-sys-motion, easing-emphasized-decelerate); opacity: 1; @@ -150,19 +150,19 @@ $_md-sys-motion: tokens.md-sys-motion-values(); opacity: var(--_disabled-unselected-icon-opacity); } - :host([checked]:hover) .icon { + :host(:hover) .checked .icon { fill: var(--_selected-hover-icon-color); } - :host([checked]:focus-within) .icon { + :host(:focus-within) .checked .icon { fill: var(--_selected-focus-icon-color); } - :host([checked]:active) .icon { + :host(:active) .checked .icon { fill: var(--_selected-pressed-icon-color); } - :host([checked][disabled]) .icon { + :host([disabled]) .checked .icon { fill: var(--_disabled-selected-icon-color); opacity: var(--_disabled-selected-icon-opacity); } diff --git a/radio/lib/radio.ts b/radio/lib/radio.ts index 0ed21a85544..c3020825d58 100644 --- a/radio/lib/radio.ts +++ b/radio/lib/radio.ts @@ -9,6 +9,7 @@ import '../../ripple/ripple.js'; import {html, isServer, LitElement, nothing} from 'lit'; import {property, query} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; import {ARIAMixinStrict} from '../../internal/aria/aria.js'; import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js'; @@ -115,29 +116,32 @@ export class Radio extends LitElement { } protected override render() { + const classes = {checked: this.checked}; // Needed for closure conformance const {ariaLabel} = this as ARIAMixinStrict; return html` - - - - - - - - - - - +
+ + + + + + + + + + + +
`; }