Skip to content

Commit

Permalink
fix: focus entered date on open with auto-open disabled (#4828) (#4830)
Browse files Browse the repository at this point in the history
Co-authored-by: Sascha Ißbrücker <[email protected]>
  • Loading branch information
vaadin-bot and sissbruecker authored Oct 25, 2022
1 parent 9f96611 commit a92e05f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/date-picker/src/vaadin-date-picker-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ export const DatePickerMixin = (subclass) =>

/** @private */
_userInputValueChanged() {
if (this.opened && this._inputValue) {
if (this._inputValue) {
const parsedDate = this._getParsedDate();

if (this._isValidDate(parsedDate)) {
Expand Down
19 changes: 18 additions & 1 deletion packages/date-picker/test/keyboard-input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import { sendKeys } from '@web/test-runner-commands';
import sinon from 'sinon';
import './not-animated-styles.js';
import '../vaadin-date-picker.js';
import { close, getFocusedCell, getOverlayContent, idleCallback, open, waitForScrollToFinish } from './common.js';
import {
close,
getFocusedCell,
getOverlayContent,
idleCallback,
open,
waitForOverlayRender,
waitForScrollToFinish,
} from './common.js';

describe('keyboard', () => {
let datepicker;
Expand Down Expand Up @@ -621,6 +629,15 @@ describe('keyboard', () => {
expect(datepicker.opened).not.to.be.true;
});

it('should focus parsed date when opening overlay', async () => {
await sendKeys({ type: '1/20/2000' });
await open(datepicker);
await waitForOverlayRender();

expect(focusedDate().getMonth()).to.equal(0);
expect(focusedDate().getDate()).to.equal(20);
});

it('should set datepicker value on blur', async () => {
await sendKeys({ type: '1/1/2000' });
await sendKeys({ press: 'Tab' });
Expand Down

0 comments on commit a92e05f

Please sign in to comment.