@@ -105,7 +105,21 @@ describe('grid-pro custom editor', () => {
105
105
expect ( cell . _content . querySelector ( 'vaadin-date-picker' ) ) . to . be . ok ;
106
106
} ) ;
107
107
108
- it ( 'should stop editing and update value when closing on outside click' , async ( ) => {
108
+ it ( 'should not stop editing when clicking inside the overlay but not on focusable element' , async ( ) => {
109
+ // Open the overlay
110
+ await sendKeys ( { press : 'ArrowDown' } ) ;
111
+ await waitForOverlayRender ( ) ;
112
+
113
+ // Click between toolbar buttons
114
+ const overlayContent = document . querySelector ( 'vaadin-date-picker-overlay-content' ) ;
115
+ const { x, y } = middleOfNode ( overlayContent . shadowRoot . querySelector ( '[part="toolbar"]' ) ) ;
116
+ await sendMouse ( { type : 'click' , position : [ Math . floor ( x ) , Math . floor ( y ) ] } ) ;
117
+ await nextRender ( ) ;
118
+
119
+ expect ( cell . _content . querySelector ( 'vaadin-date-picker' ) ) . to . be . ok ;
120
+ } ) ;
121
+
122
+ it ( 'should not stop editing and update value when closing on outside click' , async ( ) => {
109
123
// Open the overlay
110
124
await sendKeys ( { press : 'ArrowDown' } ) ;
111
125
await waitForOverlayRender ( ) ;
@@ -124,11 +138,9 @@ describe('grid-pro custom editor', () => {
124
138
await sendMouse ( { type : 'click' , position : [ 10 , 10 ] } ) ;
125
139
await nextRender ( ) ;
126
140
127
- // TODO: closing occurs in `vaadin-overlay-outside-click` listener added on global `focusin`
128
- // in grid-pro. Consider replacing it with `_shouldRemoveFocus()` check on editor `focusout`
129
- // so that we don't stop editing on outside click, to align with the combo-box behavior.
130
- expect ( cell . _content . querySelector ( 'vaadin-date-picker' ) ) . to . be . not . ok ;
131
- expect ( cell . _content . textContent ) . to . equal ( '1984-01-12' ) ;
141
+ const editor = cell . _content . querySelector ( 'vaadin-date-picker' ) ;
142
+ expect ( editor ) . to . be . ok ;
143
+ expect ( editor . value ) . to . equal ( '1984-01-12' ) ;
132
144
} ) ;
133
145
} ) ;
134
146
@@ -214,7 +226,21 @@ describe('grid-pro custom editor', () => {
214
226
await sendKeys ( { press : 'Enter' } ) ;
215
227
} ) ;
216
228
217
- it ( 'should stop editing and update value when closing on date-picker outside click' , async ( ) => {
229
+ it ( 'should not stop editing when switching between pickers using Tab' , async ( ) => {
230
+ // Move focus to the time-picker
231
+ await sendKeys ( { press : 'Tab' } ) ;
232
+ await nextRender ( ) ;
233
+ expect ( cell . _content . querySelector ( 'vaadin-date-time-picker' ) ) . to . be . ok ;
234
+
235
+ // Move focus to the date-picker
236
+ await sendKeys ( { down : 'Shift' } ) ;
237
+ await sendKeys ( { press : 'Tab' } ) ;
238
+ await sendKeys ( { up : 'Shift' } ) ;
239
+ await nextRender ( ) ;
240
+ expect ( cell . _content . querySelector ( 'vaadin-date-time-picker' ) ) . to . be . ok ;
241
+ } ) ;
242
+
243
+ it ( 'should not stop editing and update value when closing on date-picker outside click' , async ( ) => {
218
244
await sendKeys ( { press : 'ArrowDown' } ) ;
219
245
await waitForOverlayRender ( ) ;
220
246
@@ -232,16 +258,13 @@ describe('grid-pro custom editor', () => {
232
258
await sendMouse ( { type : 'click' , position : [ 10 , 10 ] } ) ;
233
259
await nextRender ( ) ;
234
260
235
- // TODO: closing occurs in `vaadin-overlay-outside-click` listener added on global `focusin`
236
- // in grid-pro. Consider replacing it with `_shouldRemoveFocus()` check on editor `focusout`
237
- // so that we don't stop editing on outside click, to align with the combo-box behavior.
238
- expect ( cell . _content . querySelector ( 'vaadin-date-time-picker' ) ) . to . be . not . ok ;
239
- expect ( cell . _content . textContent ) . to . equal ( '1984-01-12T09:00' ) ;
261
+ const editor = cell . _content . querySelector ( 'vaadin-date-time-picker' ) ;
262
+ expect ( editor ) . to . be . ok ;
263
+ expect ( editor . value ) . to . equal ( '1984-01-12T09:00' ) ;
240
264
} ) ;
241
265
242
266
it ( 'should not stop editing and update value when closing on time-picker outside click' , async ( ) => {
243
- // TODO: replace with Tab and add a separate test to not stop editing on Tab
244
- cell . _content . querySelector ( 'vaadin-time-picker' ) . focus ( ) ;
267
+ await sendKeys ( { press : 'Tab' } ) ;
245
268
246
269
// Open the overlay
247
270
await sendKeys ( { press : 'ArrowDown' } ) ;
@@ -250,6 +273,7 @@ describe('grid-pro custom editor', () => {
250
273
await sendKeys ( { press : 'ArrowDown' } ) ;
251
274
252
275
await sendMouse ( { type : 'click' , position : [ 10 , 10 ] } ) ;
276
+ await nextRender ( ) ;
253
277
254
278
const editor = cell . _content . querySelector ( 'vaadin-date-time-picker' ) ;
255
279
expect ( editor ) . to . be . ok ;
0 commit comments