No public description
PiperOrigin-RevId: 627741589
Change-Id: Icdf1310e3e90eafb9483973e1eddc9d2d9addf5c
diff --git a/switch/switch.ts b/switch/switch.ts
index aa5a23f..79f9814 100644
--- a/switch/switch.ts
+++ b/switch/switch.ts
@@ -47,6 +47,11 @@
--md-switch-selected-focus-handle-color: var(--cros-sys-on_primary);
--md-switch-selected-pressed-handle-color: var(--cros-sys-on_primary);
+ --md-switch-selected-hover-state-layer-color: var(--cros-sys-hover_on_subtle);
+ --md-switch-selected-pressed-state-layer-color: var(--cros-sys-ripple_primary);
+ --md-switch-selected-hover-state-layer-opacity: 1;
+ --md-switch-selected-pressed-state-layer-opacity: 1;
+
/* unselected */
--md-switch-track-color: var(--cros-sys-secondary);
--md-switch-hover-track-color: var(--cros-sys-secondary);
@@ -57,6 +62,11 @@
--md-switch-hover-handle-color: var(--cros-sys-on_secondary);
--md-switch-focus-handle-color: var(--cros-sys-on_secondary);
--md-switch-pressed-handle-color: var(--cros-sys-on_secondary);
+
+ --md-switch-hover-state-layer-color: var(--cros-sys-hover_on_subtle);
+ --md-switch-pressed-state-layer-color: var(--cros-sys-ripple_neutral_on_subtle);
+ --md-switch-hover-state-layer-opacity: 1;
+ --md-switch-pressed-state-layer-opacity: 1;
}
md-switch::part(focus-ring) {
@@ -118,6 +128,7 @@
?disabled=${this.disabled}
?selected=${this.selected}
@change=${this.onChange}
+ @keydown=${this.onKeyDown}
aria-label=${this.ariaLabel ?? nothing}>
</md-switch>
`;
@@ -128,6 +139,12 @@
this.dispatchEvent(new Event('change', {bubbles: true}));
}
+ private onKeyDown(e: KeyboardEvent) {
+ if (e.key === 'Enter') {
+ this.click();
+ }
+ }
+
override click() {
this.mdSwitch?.click();
}