Skip to content

Commit 4dc9391

Browse files
fix(material/slider): ensure disabled slider thumb input has 'auto' cursor
Fixes #31306
1 parent 3f0b410 commit 4dc9391

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/material/slider/slider.e2e.spec.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,6 @@ describe('MatSlider', () => {
107107
},
108108
);
109109
});
110-
111-
it('should have "auto" cursor on thumb input when slider is disabled', async () => {
112-
const slider = getStandardSlider();
113-
// Disable the slider using a script since there's no direct API in protractor
114-
// to set component properties and trigger change detection easily for this specific setup.
115-
await browser.executeScript('arguments[0].disabled = true;', slider.getWebElement());
116-
117-
// It might take a moment for the disabled styles to apply.
118-
// A small wait can help, though ideally, there'd be a more robust way to detect this.
119-
await browser.sleep(100); // Wait for styles to apply, adjust if needed.
120-
121-
const thumbInput = slider.element(by.css('.mdc-slider__input'));
122-
const cursorStyle = await thumbInput.getCssValue('cursor');
123-
expect(cursorStyle).toBe('auto');
124-
});
125110
});
126111

127112
/** Returns the current value of the slider. */

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)