Skip to content

bug(mat-slide-toggle): M3 style overrides and focus behavior do not work consistently #30945

Closed
@TerezIsCoding

Description

@TerezIsCoding

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

The new M3 styling via including slide-toggle-overrides does not work correctly for state-overlay tokens.
:root {
@include mat.slide-toggle-overrides((
...
));
}
Also, the focus behavior seems inconsistent comparing keyboard & mouse on label to mouse on button.
(See also related ticket: #26489)

Reproduction

StackBlitz link: https://stackblitz.com/edit/g1co2sxl-wa4v2ght?file=src%2Fstyles.scss,src%2Fexample%2Fslide-toggle-configurable-example.ts
or: default Angular Material example: https://material.angular.io/components/slide-toggle/examples#slide-toggle-configurable

Steps to reproduce:

  1. Change the overrides in the styles.scss in the material-ui mat-slide-toggle example or the given stackblitz example
  2. Check out the behavior for mouse click on label
  3. Compare to the behavior for mouse click on button
  4. Compare to the behavior for interaction with tab-key

Expected Behavior

  1. Color overrides: unselected-pressed-state-layer-color and selected-pressed-state-layer-color should used for active state triggered by mouse interaction on the label

  2. Opacitiy overrides: hover and focus state layer opacity should be set to the values from their token overrides (unselected-hover-state-layer-opacity, selected-hover-state-layer-opacity, unselected-focus-state-layer-opacity, selected-focus-state-layer-opacity ).

  3. Focus: the button should remain focused after all interactions (keyboard interaction,mouse interaction on the label, mouse interaction on the button

Actual Behavior

  1. Color overrides: unselected-hover-state-layer-color and selected-hover-state-layer-color is being used for active state triggered by mouse interaction on the label

  2. Opacitiy overrides: hover and focus state layer opacity are not changed by token overrides (unselected-hover-state-layer-opacity, selected-hover-state-layer-opacity, unselected-focus-state-layer-opacity, selected-focus-state-layer-opacity ). Instead a fixed value seems to be derived form a :before-:after animation.

  3. Focus: the button is only focused after keyboard interaction or mouse interaction on the label, not for mouse interaction on the button (the state seems to be removed directly after the click)

Environment

  • Angular: 19.2.0
  • CDK/Material: 19.2.0
  • Browser(s): Edge, Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/slide-toggle

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions