Skip to content

Commit 9ce023d

Browse files
fix(material/slider): ensure disabled slider thumb input has 'auto' c… (#31311)
* fix(material/slider): ensure disabled slider thumb input has 'auto' cursor Fixes #31306 * fix(material/slider): ensure disabled slider thumb input has 'auto' cursor Fixes #31306 --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent ede6331 commit 9ce023d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/material/slider/slider.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ $fallbacks: m3-slider.get-tokens();
313313
&.mdc-slider--disabled {
314314
cursor: auto;
315315
opacity: 0.38;
316+
317+
.mdc-slider__input {
318+
cursor: auto;
319+
}
316320
}
317321

318322
.mdc-slider__thumb,

src/material/slider/slider.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,22 @@ describe('MatSlider', () => {
563563
it('should set the disabled attribute on the input element', () => {
564564
expect(input._hostElement.disabled).toBeTrue();
565565
});
566+
567+
it('should have "auto" cursor on thumb input when slider is disabled', () => {
568+
// The beforeEach already creates a DisabledSlider component fixture and detects changes.
569+
// We can directly access `input` (MatSliderThumb) and its `_hostElement`.
570+
// The slider is disabled by default in this setup.
571+
// fixture.detectChanges() might be needed if there were any dynamic changes
572+
// but here we are checking the initial state of a disabled slider.
573+
// However, calling it ensures the component is stable and styles are applied.
574+
const fixture = TestBed.createComponent(DisabledSlider);
575+
fixture.detectChanges();
576+
const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider));
577+
const slider = sliderDebugElement.componentInstance;
578+
const inputThumb = slider._getInput(_MatThumb.END) as MatSliderThumb;
579+
const thumbInputElement = inputThumb._hostElement;
580+
expect(getComputedStyle(thumbInputElement).cursor).toBe('auto');
581+
});
566582
});
567583

568584
describe('disabled range slider', () => {

0 commit comments

Comments
 (0)