Skip to content

Close behavior on interacting with the editable input in IgxDateRangePicker (alignment with WC) #16125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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