Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,26 @@ describe('IgxDateRangePicker', () => {
expect(dateRange.opening.emit).toHaveBeenCalledTimes(0);
expect(dateRange.opened.emit).toHaveBeenCalledTimes(0);
}));

it('should keep the calendar open when input is focused by click and while typing', fakeAsync(() => {
fixture.componentInstance.dateRange.open();
fixture.detectChanges();
tick(DEBOUNCE_TIME);

startInput.triggerEventHandler('focus', {});
fixture.detectChanges();
UIInteractions.simulateClickAndSelectEvent(startInput.nativeElement);
fixture.detectChanges();
tick(DEBOUNCE_TIME);

expect(dateRange.collapsed).toBeFalsy();

UIInteractions.simulateTyping('01/10/202', startInput);
fixture.detectChanges();
tick(DEBOUNCE_TIME);

expect(dateRange.collapsed).toBeFalsy();
}));
});

it('should focus the last focused input after the calendar closes - dropdown', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,11 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective
this.opened.emit({ owner: this });
});

this._overlayService.closing.pipe(...this._overlaySubFilter).subscribe((e) => {
this._overlayService.closing.pipe(...this._overlaySubFilter).subscribe((e: OverlayCancelableEventArgs) => {
const isEscape = e.event && (e.event as KeyboardEvent).key === this.platform.KEYMAP.ESCAPE;
if (this.isProjectedInputTarget(e.event) && !isEscape) {
e.cancel = true;
}
this.handleClosing(e as OverlayCancelableEventArgs);
});

Expand All @@ -803,6 +807,16 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective
});
}

private isProjectedInputTarget(event: Event): boolean {
if (!this.hasProjectedInputs || !event) {
return false;
}
const path = event.composed ? event.composedPath() : [event.target];
return this.projectedInputs.some(i =>
path.includes(i.dateTimeEditor.nativeElement)
);
}

private updateValue(value: DateRange) {
this._value = value ? value : null;
this.updateInputs();
Expand Down
Loading