Skip to content

Commit caa41a9

Browse files
authored
Merge branch '9.0.x' into mkirova/fix-6701-9.0.x
2 parents 2f5a286 + dc2defc commit caa41a9

File tree

3 files changed

+57
-43
lines changed

3 files changed

+57
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ All notable changes for each version of this project will be documented in this
106106
</igx-grid>
107107
```
108108
- `IgxSlider`:
109+
- **Breaking Change** - `isContinuous` - input has been deleted. The option is not supported anymore.
109110
- `primaryTicks` input was added. Which sets the number of primary ticks
110111
- `secondaryTicks` input was added. Which sets the number of secondary ticks.
111112
- `showTicks` input was added. Which show/hide all slider ticks and tick labels.
@@ -114,7 +115,6 @@ All notable changes for each version of this project will be documented in this
114115
- `ticksOrientation` input was added. Allows to change ticks orientation to top|bottom|mirror.
115116
- `tickLabelsOrientation` input was added. Allows you to change the rotation of all tick labels from horizontal to vertical(toptobottom, bottomtotop).
116117
- `igxSliderTickLabel` directive has been introduced. Allows you to set a custom template for all tick labels.
117-
- `isContinuous` - input has been deleted. The option is not supported anymore.
118118
- `onValueChanged` - new output has been exposed. This event is emitted at the end of every slide interaction.
119119

120120
- `IgxCarousel`:

projects/igniteui-angular/src/lib/slider/slider.component.spec.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -567,15 +567,15 @@ describe('IgxSlider', () => {
567567
fixture.detectChanges();
568568

569569
expect(sliderEl).toBeDefined();
570-
let activeThumb = sliderEl.query(By.css('.igx-slider__thumb-to--active'));
571-
expect(activeThumb).not.toBeNull();
570+
let activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-to--active'));
571+
expect(activeLabel).not.toBeNull();
572572

573573
sliderEl.nativeElement.dispatchEvent( new PointerEvent('pointerup', { pointerId: 1 }));
574574
await wait(slider.thumbLabelVisibilityDuration + 10);
575575
fixture.detectChanges();
576576

577-
activeThumb = fixture.debugElement.query(By.css('.igx-slider__thumb-to--active'));
578-
expect(activeThumb).toBeNull();
577+
activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-to--active'));
578+
expect(activeLabel).toBeNull();
579579
});
580580

581581
it('should be able to change thumbLabelVisibilityDuration', async() => {
@@ -586,20 +586,20 @@ describe('IgxSlider', () => {
586586
fixture.detectChanges();
587587

588588
expect(sliderEl).toBeDefined();
589-
let activeThumb = sliderEl.query(By.css('.igx-slider__thumb-to--active'));
590-
expect(activeThumb).not.toBeNull();
589+
let activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-to--active'));
590+
expect(activeLabel).not.toBeNull();
591591

592592
sliderEl.nativeElement.dispatchEvent( new PointerEvent('pointerup', { pointerId: 1 }));
593593
await wait(750);
594594
fixture.detectChanges();
595595

596-
activeThumb = sliderEl.query(By.css('.igx-slider__thumb-to--active'));
597-
expect(activeThumb).not.toBeNull();
596+
activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-to--active'));
597+
expect(activeLabel).not.toBeNull();
598598

599599
await wait(300);
600600
fixture.detectChanges();
601-
activeThumb = sliderEl.query(By.css('.igx-slider__thumb-to--active'));
602-
expect(activeThumb).toBeNull();
601+
activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-to--active'));
602+
expect(activeLabel).toBeNull();
603603
});
604604

605605
it('rendering of the slider should corresponds to the set labels', () => {
@@ -838,15 +838,15 @@ describe('IgxSlider', () => {
838838
fixture.detectChanges();
839839

840840
expect(sliderEl).toBeDefined();
841-
let activeThumb = fixture.debugElement.query(By.css('.igx-slider__thumb-from--active'));
842-
expect(activeThumb).not.toBeNull();
841+
let activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-from--active'));
842+
expect(activeLabel).not.toBeNull();
843843

844844
sliderEl.dispatchEvent( new PointerEvent('pointerup', { pointerId: 1}));
845845
await wait(slider.thumbLabelVisibilityDuration + 10);
846846
fixture.detectChanges();
847847

848-
activeThumb = fixture.debugElement.query(By.css('.igx-slider__thumb-from--active'));
849-
expect(activeThumb).toBeNull();
848+
activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-from--active'));
849+
expect(activeLabel).toBeNull();
850850
});
851851

852852
it('should be able to change thumbLabelVisibilityDuration', async() => {
@@ -857,20 +857,20 @@ describe('IgxSlider', () => {
857857
fixture.detectChanges();
858858

859859
expect(sliderEl).toBeDefined();
860-
let activeThumb = fixture.debugElement.query(By.css('.igx-slider__thumb-from--active'));
861-
expect(activeThumb).not.toBeNull();
860+
let activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-from--active'));
861+
expect(activeLabel).not.toBeNull();
862862

863863
sliderEl.dispatchEvent( new PointerEvent('pointerup', { pointerId: 1}));
864864
await wait(750);
865865
fixture.detectChanges();
866866

867-
activeThumb = fixture.debugElement.query(By.css('.igx-slider__thumb-from--active'));
868-
expect(activeThumb).not.toBeNull();
867+
activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-from--active'));
868+
expect(activeLabel).not.toBeNull();
869869

870870
await wait(300);
871871
fixture.detectChanges();
872-
activeThumb = fixture.debugElement.query(By.css('.igx-slider__thumb-from--active'));
873-
expect(activeThumb).toBeNull();
872+
activeLabel = fixture.debugElement.query(By.css('.igx-slider__label-from--active'));
873+
expect(activeLabel).toBeNull();
874874
});
875875

876876
it('rendering of the slider should corresponds to the set labels', () => {
@@ -884,32 +884,32 @@ describe('IgxSlider', () => {
884884

885885
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', fromThumb.nativeElement, true);
886886
fixture.detectChanges();
887-
expect(fixture.componentInstance.label).toEqual({lower: 1, upper: 6});
887+
expect(fixture.componentInstance.slider.value).toEqual({lower: 1, upper: 6});
888888
expect(slider.lowerLabel).toEqual('Tuesday');
889889

890890
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', fromThumb.nativeElement, true);
891891
fixture.detectChanges();
892-
expect(fixture.componentInstance.label).toEqual({lower: 2, upper: 6});
892+
expect(fixture.componentInstance.slider.value).toEqual({lower: 2, upper: 6});
893893
expect(slider.lowerLabel).toEqual('Wednesday');
894894

895895
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', fromThumb.nativeElement, true);
896896
fixture.detectChanges();
897-
expect(fixture.componentInstance.label).toEqual({lower: 3, upper: 6});
897+
expect(fixture.componentInstance.slider.value).toEqual({lower: 3, upper: 6});
898898
expect(slider.lowerLabel).toEqual('Thursday');
899899

900900
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', fromThumb.nativeElement, true);
901901
fixture.detectChanges();
902-
expect(fixture.componentInstance.label).toEqual({lower: 4, upper: 6});
902+
expect(fixture.componentInstance.slider.value).toEqual({lower: 4, upper: 6});
903903
expect(slider.lowerLabel).toEqual('Friday');
904904

905905
UIInteractions.triggerKeyDownEvtUponElem('ArrowLeft', toThumb.nativeElement, true);
906906
fixture.detectChanges();
907-
expect(fixture.componentInstance.label).toEqual({lower: 4, upper: 5});
907+
expect(fixture.componentInstance.slider.value).toEqual({lower: 4, upper: 5});
908908
expect(slider.upperLabel).toEqual('Saturday');
909909

910910
UIInteractions.triggerKeyDownEvtUponElem('ArrowLeft', toThumb.nativeElement, true);
911911
fixture.detectChanges();
912-
expect(fixture.componentInstance.label).toEqual({lower: 4, upper: 4});
912+
expect(fixture.componentInstance.slider.value).toEqual({lower: 4, upper: 4});
913913
expect(slider.upperLabel).toEqual('Friday');
914914
});
915915

@@ -1686,19 +1686,21 @@ class SliderWithLabelsComponent {
16861686

16871687
@Component({
16881688
template: `
1689-
<igx-slider [(ngModel)]='label' [type]="type"
1690-
[labels]="['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']">
1689+
<igx-slider
1690+
[labels]="['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']"
1691+
[type]="type">
16911692
</igx-slider> `
16921693
})
16931694
class RangeSliderWithLabelsComponent {
1694-
@ViewChild(IgxSliderComponent, { read: IgxSliderComponent, static: true }) public slider: IgxSliderComponent;
1695-
public label;
1695+
@ViewChild(IgxSliderComponent, { read: IgxSliderComponent, static: true })
1696+
public slider: IgxSliderComponent;
1697+
16961698
public type = IgxSliderType.RANGE;
16971699
}
16981700

16991701
@Component({
17001702
template: `
1701-
<igx-slider [(ngModel)]='label' [type]="type"
1703+
<igx-slider [type]="type"
17021704
[labels]="['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']">
17031705
<ng-template igxSliderThumbFrom let-value let-labels="labels">
17041706
<span class="custom"> Lower {{ labels[value.lower] }}</span>

projects/igniteui-angular/src/lib/slider/slider.component.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
QueryList,
1212
ChangeDetectorRef,
1313
OnChanges,
14-
NgZone
14+
NgZone,
15+
AfterContentInit
1516
} from '@angular/core';
1617
import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
1718
import { EditorProvider } from '../core/edit-provider';
@@ -63,6 +64,7 @@ export class IgxSliderComponent implements
6364
EditorProvider,
6465
OnInit,
6566
AfterViewInit,
67+
AfterContentInit,
6668
OnChanges,
6769
OnDestroy {
6870

@@ -81,6 +83,7 @@ export class IgxSliderComponent implements
8183
private _continuous = false;
8284
private _disabled = false;
8385
private _step = 1;
86+
private _value: number | IRangeSliderValue = 0;
8487

8588
// ticks
8689
private _primaryTicks = 0;
@@ -615,18 +618,11 @@ export class IgxSliderComponent implements
615618
*/
616619
@Input()
617620
public set value(value: number | IRangeSliderValue) {
618-
if (!this.isRange) {
619-
this.upperValue = value as number - (value as number % this.step);
620-
} else {
621-
value = this.validateInitialValue(value as IRangeSliderValue);
622-
this.upperValue = (value as IRangeSliderValue).upper;
623-
this.lowerValue = (value as IRangeSliderValue).lower;
624-
}
625-
626-
this._onChangeCallback(this.value);
627-
628621
if (this._hasViewInit) {
622+
this.setValue(value);
629623
this.positionHandlersAndUpdateTrack();
624+
} else {
625+
this._value = value;
630626
}
631627
}
632628

@@ -987,6 +983,10 @@ export class IgxSliderComponent implements
987983
}
988984
}
989985

986+
public ngAfterContentInit() {
987+
this.setValue(this._value);
988+
}
989+
990990
/**
991991
* @hidden
992992
*/
@@ -1405,6 +1405,18 @@ export class IgxSliderComponent implements
14051405
return isSliderWithDifferentValue || isRangeWithOneDifferentValue;
14061406
}
14071407

1408+
public setValue(value: number | IRangeSliderValue) {
1409+
if (!this.isRange) {
1410+
this.upperValue = value as number - (value as number % this.step);
1411+
} else {
1412+
value = this.validateInitialValue(value as IRangeSliderValue);
1413+
this.upperValue = (value as IRangeSliderValue).upper;
1414+
this.lowerValue = (value as IRangeSliderValue).lower;
1415+
}
1416+
1417+
this._onChangeCallback(this.value);
1418+
}
1419+
14081420
private emitValueChanged(oldValue: number | IRangeSliderValue) {
14091421
this.onValueChange.emit({ oldValue, value: this.value });
14101422
}

0 commit comments

Comments
 (0)