@@ -105,7 +105,21 @@ describe('grid-pro custom editor', () => {
105105 expect ( cell . _content . querySelector ( 'vaadin-date-picker' ) ) . to . be . ok ;
106106 } ) ;
107107
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 ( ) => {
109123 // Open the overlay
110124 await sendKeys ( { press : 'ArrowDown' } ) ;
111125 await waitForOverlayRender ( ) ;
@@ -124,11 +138,9 @@ describe('grid-pro custom editor', () => {
124138 await sendMouse ( { type : 'click' , position : [ 10 , 10 ] } ) ;
125139 await nextRender ( ) ;
126140
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' ) ;
132144 } ) ;
133145 } ) ;
134146
@@ -214,7 +226,21 @@ describe('grid-pro custom editor', () => {
214226 await sendKeys ( { press : 'Enter' } ) ;
215227 } ) ;
216228
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 ( ) => {
218244 await sendKeys ( { press : 'ArrowDown' } ) ;
219245 await waitForOverlayRender ( ) ;
220246
@@ -232,16 +258,13 @@ describe('grid-pro custom editor', () => {
232258 await sendMouse ( { type : 'click' , position : [ 10 , 10 ] } ) ;
233259 await nextRender ( ) ;
234260
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' ) ;
240264 } ) ;
241265
242266 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' } ) ;
245268
246269 // Open the overlay
247270 await sendKeys ( { press : 'ArrowDown' } ) ;
@@ -250,6 +273,7 @@ describe('grid-pro custom editor', () => {
250273 await sendKeys ( { press : 'ArrowDown' } ) ;
251274
252275 await sendMouse ( { type : 'click' , position : [ 10 , 10 ] } ) ;
276+ await nextRender ( ) ;
253277
254278 const editor = cell . _content . querySelector ( 'vaadin-date-time-picker' ) ;
255279 expect ( editor ) . to . be . ok ;
0 commit comments