1
1
import { expect } from '@esm-bundle/chai' ;
2
- import { fixtureSync , nextRender , nextUpdate , tap } from '@vaadin/testing-helpers' ;
2
+ import { aTimeout , fixtureSync , nextRender , nextUpdate , outsideClick , tabKeyDown , tap } from '@vaadin/testing-helpers' ;
3
3
import { sendKeys , setViewport } from '@web/test-runner-commands' ;
4
4
import sinon from 'sinon' ;
5
5
import { getFocusedCell , open , touchTap , waitForOverlayRender } from './helpers.js' ;
@@ -58,6 +58,14 @@ describe('fullscreen mode', () => {
58
58
expect ( document . activeElement ) . to . not . equal ( input ) ;
59
59
} ) ;
60
60
61
+ it ( 'should not blur input element when focusing it with keyboard' , ( ) => {
62
+ const spy = sinon . spy ( input , 'blur' ) ;
63
+ tabKeyDown ( input ) ;
64
+ input . focus ( ) ;
65
+ expect ( spy . called ) . to . be . false ;
66
+ expect ( document . activeElement ) . to . equal ( input ) ;
67
+ } ) ;
68
+
61
69
it ( 'should blur input element when opening overlay' , async ( ) => {
62
70
const spy = sinon . spy ( input , 'blur' ) ;
63
71
await open ( datePicker ) ;
@@ -70,6 +78,22 @@ describe('fullscreen mode', () => {
70
78
expect ( cell ) . to . be . instanceOf ( HTMLTableCellElement ) ;
71
79
expect ( cell . getAttribute ( 'part' ) ) . to . include ( 'today' ) ;
72
80
} ) ;
81
+
82
+ it ( 'should blur input element when closing overlay on outside click' , async ( ) => {
83
+ await open ( datePicker ) ;
84
+ const spy = sinon . spy ( input , 'blur' ) ;
85
+ outsideClick ( ) ;
86
+ await aTimeout ( 0 ) ;
87
+ expect ( spy . called ) . to . be . true ;
88
+ } ) ;
89
+
90
+ it ( 'should not blur input element when closing overlay on Esc' , async ( ) => {
91
+ await open ( datePicker ) ;
92
+ const spy = sinon . spy ( input , 'blur' ) ;
93
+ await sendKeys ( { press : 'Escape' } ) ;
94
+ await aTimeout ( 0 ) ;
95
+ expect ( spy . called ) . to . be . false ;
96
+ } ) ;
73
97
} ) ;
74
98
75
99
describe ( 'auto open disabled' , ( ) => {
0 commit comments