@@ -217,6 +217,38 @@ describe('Editor', () => {
217217 await userEvent . keyboard ( 'a{arrowleft}b{arrowright}c{arrowdown}' ) ; // should commit changes on arrowdown
218218 expect ( getCellsAtRowIndex ( 0 ) [ 1 ] ) . toHaveTextContent ( / ^ a 1 b a c $ / ) ;
219219 } ) ;
220+
221+ it ( 'should close the editor when closeOnExternalRowChange is true or undefined and row is changed from outside' , async ( ) => {
222+ page . render (
223+ < EditorTest
224+ editorOptions = { {
225+ // needed to prevent editor from closing on update button click
226+ commitOnOutsideClick : false
227+ } }
228+ />
229+ ) ;
230+ await userEvent . dblClick ( getCellsAtRowIndex ( 0 ) [ 1 ] ) ;
231+ const editor = page . getByRole ( 'textbox' , { name : 'col2-editor' } ) ;
232+ await expect . element ( editor ) . toBeInTheDocument ( ) ;
233+ await userEvent . click ( page . getByRole ( 'button' , { name : 'update' } ) ) ;
234+ await expect . element ( editor ) . not . toBeInTheDocument ( ) ;
235+ } ) ;
236+
237+ it ( 'should not close the editor when closeOnExternalRowChange is false and row is changed from outside' , async ( ) => {
238+ page . render (
239+ < EditorTest
240+ editorOptions = { {
241+ commitOnOutsideClick : false ,
242+ closeOnExternalRowChange : false
243+ } }
244+ />
245+ ) ;
246+ await userEvent . dblClick ( getCellsAtRowIndex ( 0 ) [ 1 ] ) ;
247+ const editor = page . getByRole ( 'textbox' , { name : 'col2-editor' } ) ;
248+ await expect . element ( editor ) . toBeInTheDocument ( ) ;
249+ await userEvent . click ( page . getByRole ( 'button' , { name : 'update' } ) ) ;
250+ await expect . element ( editor ) . toBeInTheDocument ( ) ;
251+ } ) ;
220252 } ) ;
221253
222254 describe ( 'editor focus' , ( ) => {
@@ -376,6 +408,14 @@ function EditorTest({
376408 < button type = "button" onClick = { ( ) => onSave ?.( rows ) } >
377409 save
378410 </ button >
411+ < button
412+ type = "button"
413+ onClick = { ( ) => {
414+ setRows ( ( rows ) => rows . map ( ( row ) => ( { ...row } ) ) ) ;
415+ } }
416+ >
417+ update
418+ </ button >
379419 < DataGrid
380420 columns = { columns }
381421 rows = { rows }
0 commit comments