Skip to content

Commit 8ef934a

Browse files
authored
Merge branch '9.0.x' into ibarakov/fix-7072-9.0.x
2 parents f8ba7d3 + c1e805d commit 8ef934a

20 files changed

+226
-61
lines changed

projects/igniteui-angular/src/lib/calendar/calendar-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
379379
const result = [];
380380
start = this.getDateOnly(start);
381381
end = this.getDateOnly(end);
382-
while (start.getTime() !== end.getTime()) {
382+
while (start.getTime() < end.getTime()) {
383383
start = this.calendarModel.timedelta(start, 'day', 1);
384384
result.push(start);
385385
}

projects/igniteui-angular/src/lib/core/styles/components/grid/_excel-filtering-theme.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108

109109
%grid-excel-sort {
110110
display: block;
111-
padding: rem(8px) rem(16px);
111+
padding-top: rem(8px);
112+
padding-bottom: rem(8px);
112113

113114
header {
114115
color: igx-color($palette, 'grays', 700);
@@ -239,7 +240,8 @@
239240
}
240241

241242
%grid-excel-sort {
242-
padding: rem(8px);
243+
padding-top: rem(8px);
244+
padding-bottom: rem(8px);
243245
}
244246

245247
%grid-excel-actions {
@@ -271,7 +273,8 @@
271273
}
272274

273275
%grid-excel-sort {
274-
padding: rem(4px);
276+
padding-top: rem(4px);
277+
padding-bottom: rem(4px);
275278

276279
@extend %grid-excel-action--compact;
277280

projects/igniteui-angular/src/lib/date-picker/date-picker.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
<input
2525
class="igx-date-picker__input-date"
2626
igxInput
27-
[igxTextSelection]="true"
2827
type="text"
2928
[value]="transformedDate"
3029
[igxMask]="inputMask"
3130
[placeholder]="mask"
31+
[igxTextSelection]="true"
3232
[disabled]="disabled"
3333
[displayValuePipe]="displayValuePipe"
3434
[focusedValuePipe]="inputValuePipe"

projects/igniteui-angular/src/lib/directives/autocomplete/autocomplete.directive.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,31 @@ describe('IgxAutocomplete', () => {
593593
UIInteractions.triggerKeyDownEvtUponElem('enter', input.nativeElement, true);
594594
expect(fixture.componentInstance.townSelected).toBe('s');
595595
}));
596+
it('Should trigger onItemSelected only once when the event is cancelled (issue #7483)', fakeAsync(() => {
597+
spyOn(autocomplete.onItemSelected, 'emit').and.callThrough();
598+
599+
fixture.componentInstance.onItemSelected = (args) => { args.cancel = true; };
600+
UIInteractions.setInputElementValue(input, 's', fixture);
601+
fixture.detectChanges();
602+
tick();
603+
UIInteractions.triggerKeyDownEvtUponElem('enter', input.nativeElement, true);
604+
expect(fixture.componentInstance.townSelected).toBe('s');
605+
tick();
606+
fixture.detectChanges();
607+
expect(autocomplete.onItemSelected.emit).toHaveBeenCalledTimes(1);
608+
expect(autocomplete.onItemSelected.emit).toHaveBeenCalledWith({ value: 'Sofia', cancel: true });
609+
610+
fixture.componentInstance.onItemSelected = (args) => { args.cancel = true; };
611+
UIInteractions.setInputElementValue(input, 's', fixture);
612+
fixture.detectChanges();
613+
tick();
614+
UIInteractions.triggerKeyDownEvtUponElem('enter', input.nativeElement, true);
615+
expect(fixture.componentInstance.townSelected).toBe('s');
616+
tick();
617+
fixture.detectChanges();
618+
expect(autocomplete.onItemSelected.emit).toHaveBeenCalledTimes(2);
619+
expect(autocomplete.onItemSelected.emit).toHaveBeenCalledWith({ value: 'Sofia', cancel: true });
620+
}));
596621
it('Should call onInput/open/close methods properly', fakeAsync(() => {
597622
let startsWith = 'g';
598623
spyOn(autocomplete, 'onInput').and.callThrough();

projects/igniteui-angular/src/lib/directives/autocomplete/autocomplete.directive.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
NgModule, ElementRef, HostListener, ChangeDetectorRef, OnDestroy } from '@angular/core';
44
import { NgModel, FormControlName } from '@angular/forms';
55
import { CommonModule } from '@angular/common';
6-
import { Subject } from 'rxjs';
6+
import { Subject, Subscription } from 'rxjs';
77
import { first, takeUntil } from 'rxjs/operators';
88
import { CancelableEventArgs, IBaseEventArgs } from '../../core/utils';
99
import { OverlaySettings, AbsoluteScrollStrategy, IScrollStrategy, IPositionStrategy, AutoPositionStrategy } from '../../services/index';
@@ -68,6 +68,9 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
6868
excludePositionTarget: true
6969
};
7070

71+
/** @hidden @internal */
72+
private subscriptions: Subscription[] = [];
73+
7174
protected id: string;
7275
protected dropDownOpened$ = new Subject<boolean>();
7376
protected get model() {
@@ -280,9 +283,18 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
280283
// If no drop-down width is set, the drop-down will be as wide as the autocomplete input;
281284
this.target.width = this.target.width || (this.parentElement.clientWidth + 'px');
282285
this.target.open(this.settings);
283-
this.target.onSelection.pipe(takeUntil(this.dropDownOpened$)).subscribe(this.select);
284-
this.target.onOpened.pipe(first()).subscribe(this.highlightFirstItem);
285-
this.target.children.changes.pipe(takeUntil(this.dropDownOpened$)).subscribe(this.highlightFirstItem);
286+
287+
// unsubscribe from previous subscriptions, before creating new subscriptions.
288+
this.unsubscribe();
289+
290+
this.subscriptions.push(this.target.onSelection.pipe(takeUntil(this.dropDownOpened$)).subscribe(this.select));
291+
this.subscriptions.push(this.target.onOpened.pipe(first()).subscribe(this.highlightFirstItem));
292+
this.subscriptions.push(this.target.children.changes.pipe(takeUntil(this.dropDownOpened$)).subscribe(this.highlightFirstItem));
293+
}
294+
295+
/** @hidden @internal */
296+
private unsubscribe() {
297+
this.subscriptions.forEach(subscription => subscription.unsubscribe());
286298
}
287299

288300
private get collapsed(): boolean {

projects/igniteui-angular/src/lib/directives/input/input.directive.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,29 @@ describe('IgxInput', () => {
615615
expect(inputGroup.element.nativeElement.classList.contains(INPUT_GROUP_INVALID_CSS_CLASS)).toBe(false);
616616
expect(inputGroup.element.nativeElement.classList.contains(INPUT_GROUP_VALID_CSS_CLASS)).toBe(false);
617617
});
618+
619+
it('should not set null or undefined as input value', () => {
620+
const fixture = TestBed.createComponent(InputComponent);
621+
fixture.detectChanges();
622+
623+
const igxInput = fixture.componentInstance.igxInput;
624+
expect(igxInput.value).toBe('');
625+
626+
igxInput.value = undefined;
627+
expect(igxInput.value).toBe('');
628+
629+
igxInput.value = null;
630+
expect(igxInput.value).toBe('');
631+
632+
igxInput.value = 0;
633+
expect(igxInput.value).toBe('0');
634+
635+
igxInput.value = false;
636+
expect(igxInput.value).toBe('false');
637+
638+
igxInput.value = 'Test';
639+
expect(igxInput.value).toBe('Test');
640+
});
618641
});
619642

620643
@Component({ template: `

projects/igniteui-angular/src/lib/directives/input/input.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
7474
*/
7575
@Input('value')
7676
set value(value: any) {
77-
this.nativeElement.value = value;
77+
this.nativeElement.value = value ?? '';
7878
this.checkValidity();
7979
}
8080
/**

projects/igniteui-angular/src/lib/directives/scroll-inertia/scroll_inertia.directive.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class IgxScrollInertiaDirective implements OnInit, OnDestroy {
6262
private _nextX;
6363
private _nextY;
6464
private parentElement;
65+
private baseDeltaMultiplier = 1 / 120;
66+
private firefoxDeltaMultiplier = 1 / 30;
6567

6668
ngOnInit(): void {
6769
this._zone.runOutsideAngular(() => {
@@ -106,28 +108,30 @@ export class IgxScrollInertiaDirective implements OnInit, OnDestroy {
106108
if (evt.wheelDeltaX) {
107109
/* Option supported on Chrome, Safari, Opera.
108110
/* 120 is default for mousewheel on these browsers. Other values are for trackpads */
109-
scrollDeltaX = -evt.wheelDeltaX / 120;
111+
scrollDeltaX = -evt.wheelDeltaX * this.baseDeltaMultiplier;
110112

111113
if (-minWheelStep < scrollDeltaX && scrollDeltaX < minWheelStep) {
112114
scrollDeltaX = Math.sign(scrollDeltaX) * minWheelStep;
113115
}
114116
} else if (evt.deltaX) {
115117
/* For other browsers that don't provide wheelDelta, use the deltaY to determine direction and pass default values. */
116-
scrollDeltaX = this.calcAxisCoords(evt.deltaX, -1, 1);
118+
const deltaScaledX = evt.deltaX * (evt.deltaMode === 0 ? this.firefoxDeltaMultiplier : 1);
119+
scrollDeltaX = this.calcAxisCoords(deltaScaledX, -1, 1);
117120
}
118121

119122
/** Get delta for the Y axis*/
120123
if (evt.wheelDeltaY) {
121124
/* Option supported on Chrome, Safari, Opera.
122125
/* 120 is default for mousewheel on these browsers. Other values are for trackpads */
123-
scrollDeltaY = -evt.wheelDeltaY / 120;
126+
scrollDeltaY = -evt.wheelDeltaY * this.baseDeltaMultiplier;
124127

125128
if (-minWheelStep < scrollDeltaY && scrollDeltaY < minWheelStep) {
126129
scrollDeltaY = Math.sign(scrollDeltaY) * minWheelStep;
127130
}
128131
} else if (evt.deltaY) {
129132
/* For other browsers that don't provide wheelDelta, use the deltaY to determine direction and pass default values. */
130-
scrollDeltaY = this.calcAxisCoords(evt.deltaY, -1, 1);
133+
const deltaScaledY = evt.deltaY * (evt.deltaMode === 0 ? this.firefoxDeltaMultiplier : 1);
134+
scrollDeltaY = this.calcAxisCoords(deltaScaledY, -1, 1);
131135
}
132136
if (scrollDeltaX && this.IgxScrollInertiaDirection === 'horizontal') {
133137
this._scrollToX(

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,6 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
540540
return false;
541541
}
542542

543-
public atInexistingPage(): boolean {
544-
return this.grid.totalPages - 1 > this.grid.page;
545-
}
546-
547543
public get_row_expansion_state(record: any): boolean {
548544
const grid = this.grid;
549545
const states = grid.expansionStates;

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ <h4>{{ column.header || column.field }}</h4>
8484
</div>
8585
</header>
8686

87-
<div *ngIf="column.sortable">
88-
<ng-container *ngTemplateOutlet="sortingTemplate"></ng-container>
89-
</div>
90-
9187
<section class="igx-excel-filter__actions">
88+
<div *ngIf="column.sortable">
89+
<ng-container *ngTemplateOutlet="sortingTemplate"></ng-container>
90+
</div>
9291

9392
<div *ngIf="column.movable">
9493
<ng-container *ngTemplateOutlet="movingTemplate"></ng-container>

0 commit comments

Comments
 (0)