File tree Expand file tree Collapse file tree
e2e/testcafe-devextreme/tests/dataGrid
common/keyboardNavigation
packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4149,6 +4149,52 @@ test('DataGrid - focusedRowIndex is -1 when the first data cell is focused with
41494149 } ,
41504150} ) ) ;
41514151
4152+ test ( 'DataGrid - onFocusedCellChanged parameters should be correct when focusing the first cell (T1282664)' , async ( t ) => {
4153+ const dataGrid = new DataGrid ( '#container' ) ;
4154+
4155+ // act
4156+ await t
4157+ . click ( dataGrid . getSearchBox ( ) . input )
4158+ . pressKey ( 'tab tab tab' ) ;
4159+
4160+ // assert
4161+ const firstDataCell = dataGrid . getDataCell ( 0 , 0 ) . element ;
4162+ await t
4163+ . expect ( firstDataCell . focused )
4164+ . ok ( ) ;
4165+
4166+ const expectedFocusedCellChangedEventArgs = {
4167+ cellElement : firstDataCell ,
4168+ columnIndex : 0 ,
4169+ row : {
4170+ data : {
4171+ field_0 : 'val_0_0' ,
4172+ field_1 : 'val_0_1' ,
4173+ } ,
4174+ } ,
4175+ rowIndex : 0 ,
4176+ } ;
4177+ await checkFocusedCellChangedEventArgs ( t , expectedFocusedCellChangedEventArgs ) ;
4178+ } ) . before ( async ( ) => {
4179+ await resetFocusedEventsTestData ( ) ;
4180+
4181+ await createWidget ( 'dxDataGrid' , {
4182+ dataSource : getData ( 1 , 2 ) ,
4183+ keyExpr : 'field_0' ,
4184+ showBorders : true ,
4185+ searchPanel : {
4186+ visible : true ,
4187+ } ,
4188+ onFocusedCellChanged ( e ) {
4189+ ( window as any ) . focusedEventsTestData . push ( { name : 'onFocusedCellChanged' , args : e } ) ;
4190+ } ,
4191+ } ) ;
4192+ } ) . after ( async ( ) => {
4193+ await ClientFunction ( ( ) => {
4194+ delete ( window as any ) . focusedEventsTestData ;
4195+ } ) ( ) ;
4196+ } ) ;
4197+
41524198test ( 'DataGrid - Cell focus in edit mode does not work correctly if a cell has a disabled editor (T1177434)' , async ( t ) => {
41534199 const dataGrid = new DataGrid ( '#container' ) ;
41544200
Original file line number Diff line number Diff line change @@ -35,7 +35,11 @@ const getFocusedCellChangedEventArgs = ClientFunction(
3535 . args ;
3636
3737 return {
38+ cellElementText : eventArgs . cellElement . get ( 0 ) . textContent ,
3839 columnIndex : eventArgs . columnIndex ,
40+ row : {
41+ data : eventArgs . row . data ,
42+ } ,
3943 rowIndex : eventArgs . rowIndex ,
4044 } ;
4145 } ,
@@ -102,7 +106,11 @@ export const checkFocusedRowChangingEventArgs = async (
102106export const checkFocusedCellChangedEventArgs = async (
103107 t : TestController ,
104108 expectedArgs : {
109+ cellElement ?: Selector ;
105110 columnIndex : number ;
111+ row ?: {
112+ data : any ;
113+ } ;
106114 rowIndex : number ;
107115 } ,
108116) : Promise < void > => {
@@ -113,6 +121,19 @@ export const checkFocusedCellChangedEventArgs = async (
113121 . eql ( expectedArgs . columnIndex )
114122 . expect ( args . rowIndex )
115123 . eql ( expectedArgs . rowIndex ) ;
124+
125+ if ( expectedArgs . row ?. data ) {
126+ await t
127+ . expect ( args . row . data )
128+ . eql ( expectedArgs . row . data ) ;
129+ }
130+
131+ if ( expectedArgs . cellElement ) {
132+ const expectedCellElementText = await expectedArgs . cellElement . textContent ;
133+ await t
134+ . expect ( args . cellElementText )
135+ . eql ( expectedCellElementText ) ;
136+ }
116137} ;
117138
118139export const checkFocusedRowChangedEventArgs = async (
Original file line number Diff line number Diff line change @@ -239,6 +239,7 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo
239239 const isCell = $element . is ( 'td' ) ;
240240 const needSetFocusPosition = ( this . option ( 'focusedRowIndex' ) ?? - 1 ) < 0 ;
241241 if ( isCell && needSetFocusPosition ) {
242+ this . _focusView ( ) ;
242243 this . _updateFocusedCellPosition ( $element ) ;
243244 }
244245 }
You can’t perform that action at this time.
0 commit comments