mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(slider): unable to reset tickInterval after it has been set (#3488)
Fixes user not being allowed to reset the `tickInterval` after it has been set to a valid value. Fixes #3452.
This commit is contained in:
committed by
mmalerba
parent
cdb3763be7
commit
b9b014ae1b
@@ -517,6 +517,17 @@ describe('MdSlider', () => {
|
||||
expect(ticksElement.style.transform).toContain('translateX(9%)');
|
||||
expect(ticksContainerElement.style.transform).toBe('translateX(-9%)');
|
||||
});
|
||||
|
||||
it('should be able to reset the tick interval after it has been set', () => {
|
||||
expect(sliderNativeElement.classList)
|
||||
.toContain('mat-slider-has-ticks', 'Expected element to have ticks initially.');
|
||||
|
||||
fixture.componentInstance.tickInterval = null;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(sliderNativeElement.classList)
|
||||
.not.toContain('mat-slider-has-ticks', 'Expected element not to have ticks after reset.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('slider with thumb label', () => {
|
||||
@@ -1248,10 +1259,12 @@ class SliderWithStep {
|
||||
class SliderWithAutoTickInterval { }
|
||||
|
||||
@Component({
|
||||
template: `<md-slider step="3" tickInterval="6"></md-slider>`,
|
||||
template: `<md-slider step="3" [tickInterval]="tickInterval"></md-slider>`,
|
||||
styles: [styles],
|
||||
})
|
||||
class SliderWithSetTickInterval { }
|
||||
class SliderWithSetTickInterval {
|
||||
tickInterval = 6;
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: `<md-slider thumbLabel></md-slider>`,
|
||||
|
||||
@@ -164,8 +164,14 @@ export class MdSlider implements ControlValueAccessor {
|
||||
*/
|
||||
@Input()
|
||||
get tickInterval() { return this._tickInterval; }
|
||||
set tickInterval(v) {
|
||||
this._tickInterval = (v == 'auto') ? v : coerceNumberProperty(v, <number>this._tickInterval);
|
||||
set tickInterval(value) {
|
||||
if (value === 'auto') {
|
||||
this._tickInterval = 'auto';
|
||||
} else if (typeof value === 'number' || typeof value === 'string') {
|
||||
this._tickInterval = coerceNumberProperty(value, this._tickInterval as number);
|
||||
} else {
|
||||
this._tickInterval = 0;
|
||||
}
|
||||
}
|
||||
private _tickInterval: 'auto' | number = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user