Skip to content
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

fix: commit focused date on outside click #5670

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
1 change: 1 addition & 0 deletions packages/date-picker/src/vaadin-date-picker-light.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
fullscreen$="[[_fullscreen]]"
opened="{{opened}}"
on-vaadin-overlay-escape-press="_onOverlayEscapePress"
on-vaadin-overlay-outside-click="_onOverlayOutsideClick"
on-vaadin-overlay-open="_onOverlayOpened"
on-vaadin-overlay-closing="_onOverlayClosed"
restore-focus-on-close
Expand Down
5 changes: 5 additions & 0 deletions packages/date-picker/src/vaadin-date-picker-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,11 @@ export const DatePickerMixin = (subclass) =>
this._close();
}

/** @protected */
_onOverlayOutsideClick() {
this._applyInputValue(this._selectedDate);
vursen marked this conversation as resolved.
Show resolved Hide resolved
}

/** @protected */
_onOverlayOpened() {
const content = this._overlayContent;
Expand Down
1 change: 1 addition & 0 deletions packages/date-picker/src/vaadin-date-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
theme$="[[_theme]]"
opened="{{opened}}"
on-vaadin-overlay-escape-press="_onOverlayEscapePress"
on-vaadin-overlay-outside-click="_onOverlayOutsideClick"
on-vaadin-overlay-open="_onOverlayOpened"
on-vaadin-overlay-closing="_onOverlayClosed"
restore-focus-on-close
Expand Down
12 changes: 12 additions & 0 deletions packages/date-picker/test/dropdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ describe('dropdown', () => {
await aTimeout(0);
expect(datePicker.hasAttribute('focus-ring')).to.be.false;
});

it('should clear deselected date from input after outside click', async () => {
await open(datePicker);
// Move focus to the calendar
await sendKeys({ press: 'Tab' });
// Select and deselect date
await sendKeys({ press: 'Space' });
await sendKeys({ press: 'Space' });
outsideClick();
await aTimeout(0);
expect(input.value).to.be.empty;
});
});

describe('date tap', () => {
Expand Down