[mat-slider] slider is visually focused when parent is focused and uses cdkMonitorSubtreeFocus directive #14958
Labels
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
mat-slider will be styled as if focused if a parent element to the slider has its focus being monitored with something like the cdkMonitorSubtreeFocus directive.
What is the expected behavior?
Focusing an element on a page should not cause an unrelated mat-slider to become focused.
What is the current behavior?
If a parent element to the mat-slider has the focus of it and its children being monitored, it will also cause mat-slider to be focused when the parent is keyboard focused.
What are the steps to reproduce?
https://stackblitz.com/edit/angular-material2-issue-ykmdsb
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Material Version: 7.0.2
Is there anything else we should know?
I believe this is being caused by the following css rule:
https://github.com/angular/material2/blob/master/src/lib/slider/slider.scss#L97
It specifies that any parent of .mat-slider-focus-ring with the .cdk-keyboard-focused or .cdk-program-focused class should apply the focus styles to .mat-slider-focus-ring.
I believe specifying that the .cdk-*-focused selectors should apply only to a .mat-slider parent should be enough to fix this issue.
The text was updated successfully, but these errors were encountered: