From 3f0b410f7220dd2e0a3192a9f94aa0809515396f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 16:54:17 +0000 Subject: [PATCH 1/2] fix(material/slider): ensure disabled slider thumb input has 'auto' cursor Fixes #31306 --- src/material/slider/slider.e2e.spec.ts | 15 +++++++++++++++ src/material/slider/slider.scss | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/material/slider/slider.e2e.spec.ts b/src/material/slider/slider.e2e.spec.ts index f402c4645211..9b6a2efac4cf 100644 --- a/src/material/slider/slider.e2e.spec.ts +++ b/src/material/slider/slider.e2e.spec.ts @@ -107,6 +107,21 @@ describe('MatSlider', () => { }, ); }); + + it('should have "auto" cursor on thumb input when slider is disabled', async () => { + const slider = getStandardSlider(); + // Disable the slider using a script since there's no direct API in protractor + // to set component properties and trigger change detection easily for this specific setup. + await browser.executeScript('arguments[0].disabled = true;', slider.getWebElement()); + + // It might take a moment for the disabled styles to apply. + // A small wait can help, though ideally, there'd be a more robust way to detect this. + await browser.sleep(100); // Wait for styles to apply, adjust if needed. + + const thumbInput = slider.element(by.css('.mdc-slider__input')); + const cursorStyle = await thumbInput.getCssValue('cursor'); + expect(cursorStyle).toBe('auto'); + }); }); /** Returns the current value of the slider. */ diff --git a/src/material/slider/slider.scss b/src/material/slider/slider.scss index 288fa537bdde..6f2888d041e6 100644 --- a/src/material/slider/slider.scss +++ b/src/material/slider/slider.scss @@ -313,6 +313,10 @@ $fallbacks: m3-slider.get-tokens(); &.mdc-slider--disabled { cursor: auto; opacity: 0.38; + + .mdc-slider__input { + cursor: auto; + } } .mdc-slider__thumb, From 4dc93912937b9f1ec64022840445a3368cb33fad Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 17:19:48 +0000 Subject: [PATCH 2/2] fix(material/slider): ensure disabled slider thumb input has 'auto' cursor Fixes #31306 --- src/material/slider/slider.e2e.spec.ts | 15 --------------- src/material/slider/slider.spec.ts | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/material/slider/slider.e2e.spec.ts b/src/material/slider/slider.e2e.spec.ts index 9b6a2efac4cf..f402c4645211 100644 --- a/src/material/slider/slider.e2e.spec.ts +++ b/src/material/slider/slider.e2e.spec.ts @@ -107,21 +107,6 @@ describe('MatSlider', () => { }, ); }); - - it('should have "auto" cursor on thumb input when slider is disabled', async () => { - const slider = getStandardSlider(); - // Disable the slider using a script since there's no direct API in protractor - // to set component properties and trigger change detection easily for this specific setup. - await browser.executeScript('arguments[0].disabled = true;', slider.getWebElement()); - - // It might take a moment for the disabled styles to apply. - // A small wait can help, though ideally, there'd be a more robust way to detect this. - await browser.sleep(100); // Wait for styles to apply, adjust if needed. - - const thumbInput = slider.element(by.css('.mdc-slider__input')); - const cursorStyle = await thumbInput.getCssValue('cursor'); - expect(cursorStyle).toBe('auto'); - }); }); /** Returns the current value of the slider. */ diff --git a/src/material/slider/slider.spec.ts b/src/material/slider/slider.spec.ts index 48b45d9f0362..9583826e1ecf 100644 --- a/src/material/slider/slider.spec.ts +++ b/src/material/slider/slider.spec.ts @@ -563,6 +563,22 @@ describe('MatSlider', () => { it('should set the disabled attribute on the input element', () => { expect(input._hostElement.disabled).toBeTrue(); }); + + it('should have "auto" cursor on thumb input when slider is disabled', () => { + // The beforeEach already creates a DisabledSlider component fixture and detects changes. + // We can directly access `input` (MatSliderThumb) and its `_hostElement`. + // The slider is disabled by default in this setup. + // fixture.detectChanges() might be needed if there were any dynamic changes + // but here we are checking the initial state of a disabled slider. + // However, calling it ensures the component is stable and styles are applied. + const fixture = TestBed.createComponent(DisabledSlider); + fixture.detectChanges(); + const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); + const slider = sliderDebugElement.componentInstance; + const inputThumb = slider._getInput(_MatThumb.END) as MatSliderThumb; + const thumbInputElement = inputThumb._hostElement; + expect(getComputedStyle(thumbInputElement).cursor).toBe('auto'); + }); }); describe('disabled range slider', () => {