fix(datepicker): close with outside click (#386)

This commit is contained in:
Erik Kroes 2019-11-27 14:19:59 +01:00 committed by Thomas Allmer
parent 3abb65da33
commit b34b399e17
2 changed files with 15 additions and 1 deletions

View file

@ -264,6 +264,7 @@ export class LionInputDatepicker extends OverlayMixin(LionInputDate) {
contentNode,
invokerNode,
elementToFocusAfterHide: invokerNode,
hidesOnOutsideClick: true,
});
return ctrl;
}

View file

@ -1,4 +1,4 @@
import { expect, fixture, defineCE } from '@open-wc/testing';
import { expect, fixture, defineCE, aTimeout } from '@open-wc/testing';
import sinon from 'sinon';
import { html, LitElement } from '@lion/core';
import { MaxDate, MinDate, MinMaxDate, IsDateDisabled } from '@lion/validate';
@ -99,6 +99,19 @@ describe('<lion-input-datepicker>', () => {
expect(elObj.overlayController.isShown).to.equal(false);
});
it('closes the calendar via outside click', async () => {
const el = await fixture(html`
<lion-input-datepicker></lion-input-datepicker>
`);
const elObj = new DatepickerInputObject(el);
await elObj.openCalendar();
expect(elObj.overlayController.isShown).to.equal(true);
document.body.click();
await aTimeout();
expect(elObj.overlayController.isShown).to.be.false;
});
/**
* Not in scope:
* - centralDate can be overridden