Skip to content

Commit 70e912b

Browse files
authored
Merge branch '20.0.x' into ikitanov/fix#15913-20.0.x
2 parents 386a3e4 + e289b14 commit 70e912b

File tree

8 files changed

+119
-17
lines changed

8 files changed

+119
-17
lines changed

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,13 @@ describe('IgxDateTimeEditor', () => {
11231123
inputElement.triggerEventHandler('focus', {});
11241124
fixture.detectChanges();
11251125
dateTimeEditorDirective.nativeElement.setSelectionRange(1, 1);
1126-
inputElement.triggerEventHandler('wheel', new WheelEvent('wheel', { deltaY: 1 }));
1126+
// typical wheel scrolls are 120px and the date-editor employs touchpad-friendly implementation
1127+
// that accumulates to 50 before incrementing/decrementing
1128+
// we'll test the behavior by doing two scrolls with the first one not expected to trigger a change
1129+
inputElement.triggerEventHandler('wheel', new WheelEvent('wheel', { deltaY: 20 }));
1130+
fixture.detectChanges();
1131+
expect(dateTimeEditorDirective.value.getDate()).toEqual(today.getDate());
1132+
inputElement.triggerEventHandler('wheel', new WheelEvent('wheel', { deltaY: 40 }));
11271133
fixture.detectChanges();
11281134
expect(dateTimeEditorDirective.value.getDate()).toEqual(today.getDate() - 1);
11291135
}));

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
228228
@Output()
229229
public validationFailed = new EventEmitter<IgxDateTimeEditorEventArgs>();
230230

231+
232+
private readonly SCROLL_THRESHOLD = 50;
231233
private _inputFormat: string;
234+
private _scrollAccumulator = 0;
232235
private _displayFormat: string;
233236
private _oldValue: Date;
234237
private _dateValue: Date;
@@ -313,10 +316,14 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
313316
}
314317
event.preventDefault();
315318
event.stopPropagation();
316-
if (event.deltaY > 0) {
317-
this.decrement();
318-
} else {
319-
this.increment();
319+
this._scrollAccumulator += event.deltaY;
320+
if (Math.abs(this._scrollAccumulator) > this.SCROLL_THRESHOLD) {
321+
if (this._scrollAccumulator > 0) {
322+
this.decrement();
323+
} else {
324+
this.increment();
325+
}
326+
this._scrollAccumulator = 0;
320327
}
321328
}
322329

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {
1+
import { useAnimation } from '@angular/animations';
2+
import {
23
ChangeDetectionStrategy,
34
ChangeDetectorRef,
45
Component,
@@ -52,6 +53,7 @@ import { IgxFocusDirective } from '../directives/focus/focus.directive';
5253
import { IgxInputDirective } from '../directives/input/input.directive';
5354
import { IgxInputGroupComponent } from '../input-group/input-group.component';
5455
import { IgxChipComponent } from '../chips/chip.component';
56+
import { fadeOut, scaleInCenter } from 'igniteui-angular/animations';
5557

5658
/**
5759
* Providing reference to `IgxGridCellComponent`:
@@ -883,7 +885,9 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy, CellT
883885
modal: false,
884886
positionStrategy: new AutoPositionStrategy({
885887
horizontalStartPoint: HorizontalAlignment.Center,
886-
horizontalDirection: HorizontalAlignment.Center
888+
horizontalDirection: HorizontalAlignment.Center,
889+
openAnimation: useAnimation(scaleInCenter, { params: { duration: '150ms' } }),
890+
closeAnimation: useAnimation(fadeOut, { params: { duration: '75ms' } })
887891
})
888892
}
889893
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
[placeholder]="inputValuePlaceholder"
3131
[disabled]="expressionUI.expression.condition && expressionUI.expression.condition.isUnary"
3232
autocomplete="off"
33-
[value]="expressionUI.expression.searchVal"
34-
(input)="onValuesInput($event)"
33+
[(ngModel)]="expressionUI.expression.searchVal"
34+
(blur)="updateSearchValueOnBlur($event)"
3535
/>
3636
</igx-input-group>
3737

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-default-expression.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ChangeDetectorRef,
88
ViewChild
99
} from '@angular/core';
10+
import { FormsModule } from '@angular/forms';
1011
import { IgxButtonGroupComponent } from '../../../buttonGroup/buttonGroup.component';
1112
import { GridColumnDataType, DataUtil } from '../../../data-operations/data-util';
1213
import { IFilteringOperation } from '../../../data-operations/filtering-condition';
@@ -41,7 +42,7 @@ export interface ILogicOperatorChangedArgs extends IBaseEventArgs {
4142
@Component({
4243
selector: 'igx-excel-style-default-expression',
4344
templateUrl: './excel-style-default-expression.component.html',
44-
imports: [IgxSelectComponent, IgxPrefixDirective, IgxIconComponent, IgxSelectItemComponent, IgxInputGroupComponent, IgxInputDirective, IgxButtonDirective, IgxButtonGroupComponent, IgxOverlayOutletDirective, IgxIconButtonDirective]
45+
imports: [FormsModule, IgxSelectComponent, IgxPrefixDirective, IgxIconComponent, IgxSelectItemComponent, IgxInputGroupComponent, IgxInputDirective, IgxButtonDirective, IgxButtonGroupComponent, IgxOverlayOutletDirective, IgxIconButtonDirective]
4546
})
4647
export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
4748
@Input()
@@ -163,7 +164,7 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
163164
return this.grid.resourceStrings[`igx_grid_filter_${name}`] || name;
164165
}
165166

166-
public onValuesInput(eventArgs) {
167+
public updateSearchValueOnBlur(eventArgs) {
167168
this.expressionUI.expression.searchVal = DataUtil.parseValue(this.column.dataType, eventArgs.target.value);
168169
}
169170

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,12 +3814,15 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
38143814

38153815
// set first expression's value
38163816
GridFunctions.setInputValueESF(fix, 0, 0);
3817+
tick(100);
38173818

38183819
// select second expression's operator
38193820
GridFunctions.setOperatorESF(fix, 1, 1);
3821+
tick(100);
38203822

38213823
// set second expression's value
38223824
GridFunctions.setInputValueESF(fix, 1, 20);
3825+
tick(100);
38233826

38243827
GridFunctions.clickApplyExcelStyleCustomFiltering(fix);
38253828

@@ -6302,6 +6305,55 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
63026305
expect(input.value).toBe('');
63036306
});
63046307
}));
6308+
6309+
it('should correctly filter negative decimal values in Excel Style filtering', fakeAsync(() => {
6310+
GridFunctions.clickExcelFilterIcon(fix, 'Downloads');
6311+
tick();
6312+
fix.detectChanges();
6313+
6314+
GridFunctions.clickExcelFilterCascadeButton(fix);
6315+
tick();
6316+
fix.detectChanges();
6317+
6318+
GridFunctions.clickOperatorFromCascadeMenu(fix, 2);
6319+
tick();
6320+
fix.detectChanges();
6321+
6322+
GridFunctions.setInputValueESF(fix, 0, '-1');
6323+
tick(100);
6324+
fix.detectChanges();
6325+
expect(GridFunctions.getExcelFilteringInput(fix, 0).value).toBe('-1');
6326+
6327+
const applyButton = GridFunctions.getApplyExcelStyleCustomFiltering(fix);
6328+
applyButton.click();
6329+
tick(100);
6330+
fix.detectChanges();
6331+
6332+
expect(grid.filteredData.length).toBe(8);
6333+
6334+
GridFunctions.clickExcelFilterIcon(fix, 'Downloads');
6335+
tick();
6336+
fix.detectChanges();
6337+
6338+
GridFunctions.clickExcelFilterCascadeButton(fix);
6339+
tick();
6340+
fix.detectChanges();
6341+
6342+
GridFunctions.clickOperatorFromCascadeMenu(fix, 2);
6343+
tick();
6344+
fix.detectChanges();
6345+
6346+
GridFunctions.setInputValueESF(fix, 0, '-0.1');
6347+
tick(100);
6348+
fix.detectChanges();
6349+
expect(GridFunctions.getExcelFilteringInput(fix, 0).value).toBe('-0.1');
6350+
6351+
applyButton.click();
6352+
tick(100);
6353+
fix.detectChanges();
6354+
6355+
expect(grid.filteredData.length).toBe(8);
6356+
}));
63056357
});
63066358

63076359
describe('Templates: ', () => {

projects/igniteui-angular/src/lib/grids/grid/grid-validation.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { UIInteractions } from '../../test-utils/ui-interactions.spec';
1717
import { IGridFormGroupCreatedEventArgs } from '../common/grid.interface';
1818
import { IgxTreeGridComponent } from '../tree-grid/tree-grid.component';
1919
import { IgxGridComponent } from './grid.component';
20+
import { AutoPositionStrategy, HorizontalAlignment, IgxOverlayService, VerticalAlignment } from '../../services/public_api';
2021

2122
describe('IgxGrid - Validation #grid', () => {
2223

@@ -187,6 +188,18 @@ describe('IgxGrid - Validation #grid', () => {
187188
const erorrMessage = cell.errorTooltip.first.elementRef.nativeElement.children[0].textContent;
188189
expect(erorrMessage).toEqual(' Entry should be at least 4 character(s) long ');
189190

191+
const overlayService = TestBed.inject(IgxOverlayService);
192+
const info = overlayService.getOverlayById(cell.errorTooltip.first.overlayId);
193+
const positionSettings = info.settings.positionStrategy.settings;
194+
195+
expect(info.settings.positionStrategy instanceof AutoPositionStrategy).toBe(true);
196+
expect(positionSettings.horizontalStartPoint).toEqual(HorizontalAlignment.Center);
197+
expect(positionSettings.horizontalDirection).toEqual(HorizontalAlignment.Center);
198+
expect(positionSettings.verticalStartPoint).toEqual(VerticalAlignment.Bottom);
199+
expect(positionSettings.verticalDirection).toEqual(VerticalAlignment.Bottom);
200+
expect(positionSettings.openAnimation.options.params).toEqual({ duration: '150ms' });
201+
expect(positionSettings.closeAnimation.options.params).toEqual({ duration: '75ms' });
202+
190203
cell.errorTooltip.first.close();
191204
tick();
192205
fixture.detectChanges();

projects/igniteui-angular/src/lib/time-picker/time-picker.directives.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ export class IgxItemListDirective implements OnInit, OnDestroy {
3434

3535
public isActive: boolean;
3636

37+
private readonly SCROLL_THRESHOLD = 50;
38+
private readonly PAN_THRESHOLD = 10;
39+
40+
/**
41+
* accumulates wheel scrolls and triggers a change action above SCROLL_THRESHOLD
42+
*/
43+
private scrollAccumulator = 0;
44+
3745
constructor(
3846
@Inject(IGX_TIME_PICKER_COMPONENT) public timePicker: IgxTimePickerBase,
3947
private elementRef: ElementRef,
@@ -170,24 +178,35 @@ export class IgxItemListDirective implements OnInit, OnDestroy {
170178
event.preventDefault();
171179
event.stopPropagation();
172180

173-
const delta = event.deltaY;
174-
if (delta !== 0) {
175-
this.nextItem(delta);
181+
this.scrollAccumulator += event.deltaY;
182+
if (Math.abs(this.scrollAccumulator) > this.SCROLL_THRESHOLD) {
183+
this.nextItem(this.scrollAccumulator);
184+
this.scrollAccumulator = 0;
176185
}
177186
}
178187

179188
/**
180189
* @hidden @internal
181190
*/
182191
public ngOnInit() {
183-
const hammerOptions: HammerOptions = { recognizers: [[HammerGesturesManager.Hammer?.Pan, { direction: HammerGesturesManager.Hammer?.DIRECTION_VERTICAL, threshold: 10 }]] };
192+
const hammerOptions: HammerOptions = {
193+
recognizers: [
194+
[
195+
HammerGesturesManager.Hammer?.Pan,
196+
{
197+
direction: HammerGesturesManager.Hammer?.DIRECTION_VERTICAL,
198+
threshold: this.PAN_THRESHOLD
199+
}
200+
]
201+
]
202+
};
184203
this.touchManager.addEventListener(this.elementRef.nativeElement, 'pan', this.onPanMove, hammerOptions);
185204
}
186205

187206
/**
188207
* @hidden @internal
189208
*/
190-
public ngOnDestroy() {
209+
public ngOnDestroy() {
191210
this.touchManager.destroy();
192211
}
193212

@@ -355,7 +374,7 @@ export class IgxTimeItemDirective {
355374
private getHourPart(date: Date): string {
356375
const inputDateParts = DateTimeUtil.parseDateTimeFormat(this.timePicker.appliedFormat);
357376
const hourPart = inputDateParts.find(element => element.type === 'hours');
358-
const ampmPart = inputDateParts.find(element =>element.format.indexOf('a') !== -1 || element.format === 'tt');
377+
const ampmPart = inputDateParts.find(element => element.format.indexOf('a') !== -1 || element.format === 'tt');
359378
const hour = DateTimeUtil.getPartValue(date, hourPart, hourPart.format.length);
360379
if (ampmPart) {
361380
const ampm = DateTimeUtil.getPartValue(date, ampmPart, ampmPart.format.length);

0 commit comments

Comments
 (0)