Skip to content
Merged
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
7 changes: 7 additions & 0 deletions packages/date-picker/src/vaadin-date-picker-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ export const DatePickerMixin = (subclass) =>
super._onFocus(event);

if (this._noInput && !isKeyboardActive()) {
// Blur to hide the virtual keyboard, but do not validate.
this.__ignoreInternalBlur = true;
Comment thread
web-padawan marked this conversation as resolved.
event.target.blur();
this.__ignoreInternalBlur = false;
}
}

Expand All @@ -470,6 +473,10 @@ export const DatePickerMixin = (subclass) =>
_onBlur(event) {
super._onBlur(event);

if (this.__ignoreInternalBlur) {
return;
}

if (!this.opened) {
this.__commitParsedOrFocusedDate();

Expand Down
56 changes: 55 additions & 1 deletion packages/date-picker/test/fullscreen.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@vaadin/chai-plugins';
import { sendKeys, setViewport } from '@vaadin/test-runner-commands';
import { aTimeout, fixtureSync, nextRender, outsideClick, tabKeyDown, tap } from '@vaadin/testing-helpers';
import { aTimeout, fixtureSync, nextRender, nextUpdate, outsideClick, tabKeyDown, tap } from '@vaadin/testing-helpers';
import sinon from 'sinon';
import '../src/vaadin-date-picker.js';
import { getFocusableCell, open, touchTap, untilOverlayRendered } from './helpers.js';
Expand Down Expand Up @@ -156,6 +156,60 @@
});
});

describe('validation', () => {
let validateSpy;

beforeEach(async () => {
datePicker.required = true;
await nextUpdate(datePicker);
validateSpy = sinon.spy(datePicker, 'validate');
});

it('should not validate when focusing the input', () => {

Check failure on line 168 in packages/date-picker/test/fullscreen.test.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ__QRlMr8kWpJfauk89&open=AZ__QRlMr8kWpJfauk89&pullRequest=12434
input.focus();
expect(validateSpy.called).to.be.false;
expect(datePicker.invalid).to.be.false;
});

it('should not validate when opening overlay on input tap', async () => {

Check failure on line 174 in packages/date-picker/test/fullscreen.test.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ__QRlMr8kWpJfauk8-&open=AZ__QRlMr8kWpJfauk8-&pullRequest=12434
input.focus();
tap(input);
await untilOverlayRendered(datePicker);
expect(validateSpy.called).to.be.false;
expect(datePicker.invalid).to.be.false;
});

it('should validate when closing overlay on outside click', async () => {

Check failure on line 182 in packages/date-picker/test/fullscreen.test.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ__QRlMr8kWpJfauk8_&open=AZ__QRlMr8kWpJfauk8_&pullRequest=12434
Comment thread
web-padawan marked this conversation as resolved.
await open(datePicker);
validateSpy.resetHistory();

outsideClick();
await nextRender();

expect(validateSpy.called).to.be.true;
expect(datePicker.invalid).to.be.true;
});

it('should validate on blur after the input has been blurred internally', async () => {

Check failure on line 193 in packages/date-picker/test/fullscreen.test.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ__UAUglSeWiVSBEsh9&open=AZ__UAUglSeWiVSBEsh9&pullRequest=12434
input.focus();
tap(input);
await untilOverlayRendered(datePicker);
datePicker.close();
await nextRender();

// Make the input focusable
datePicker.autoOpenDisabled = true;
await nextUpdate(datePicker);
validateSpy.resetHistory();

input.focus();
input.blur();

expect(validateSpy.called).to.be.true;
expect(datePicker.invalid).to.be.true;
});
});

describe('buttons', () => {
let overlayContent;

Expand Down