Skip to content

Commit 909ddbd

Browse files
authored
Merge branch '19.2.x' into ikitanov/fix#15913-19.2.x
2 parents eab4441 + 87246e3 commit 909ddbd

File tree

6 files changed

+100
-15
lines changed

6 files changed

+100
-15
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
@@ -229,7 +229,10 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
229229
@Output()
230230
public validationFailed = new EventEmitter<IgxDateTimeEditorEventArgs>();
231231

232+
233+
private readonly SCROLL_THRESHOLD = 50;
232234
private _inputFormat: string;
235+
private _scrollAccumulator = 0;
233236
private _displayFormat: string;
234237
private _oldValue: Date;
235238
private _dateValue: Date;
@@ -314,10 +317,14 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
314317
}
315318
event.preventDefault();
316319
event.stopPropagation();
317-
if (event.deltaY > 0) {
318-
this.decrement();
319-
} else {
320-
this.increment();
320+
this._scrollAccumulator += event.deltaY;
321+
if (Math.abs(this._scrollAccumulator) > this.SCROLL_THRESHOLD) {
322+
if (this._scrollAccumulator > 0) {
323+
this.decrement();
324+
} else {
325+
this.increment();
326+
}
327+
this._scrollAccumulator = 0;
321328
}
322329
}
323330

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
@@ -3813,12 +3813,15 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
38133813

38143814
// set first expression's value
38153815
GridFunctions.setInputValueESF(fix, 0, 0);
3816+
tick(100);
38163817

38173818
// select second expression's operator
38183819
GridFunctions.setOperatorESF(fix, 1, 1);
3820+
tick(100);
38193821

38203822
// set second expression's value
38213823
GridFunctions.setInputValueESF(fix, 1, 20);
3824+
tick(100);
38223825

38233826
GridFunctions.clickApplyExcelStyleCustomFiltering(fix);
38243827

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

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

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)