@@ -2117,3 +2117,82 @@ test('Horizontal scrollbar should not appear when columnHidingEnabled is true an
21172117 useNative : true ,
21182118 } ,
21192119} ) ) ;
2120+
2121+ test ( 'navigateToRow should scroll to the correct row with virtual scrolling (T1220800)' , async ( t ) => {
2122+ const dataGrid = new DataGrid ( '#container' ) ;
2123+ const targetKey = 901 ;
2124+
2125+ await t . expect ( dataGrid . isReady ( ) ) . ok ( ) ;
2126+
2127+ // act
2128+ await dataGrid . apiNavigateToRow ( targetKey ) ;
2129+
2130+ // assert
2131+ await t
2132+ . expect ( dataGrid . isReady ( ) )
2133+ . ok ( )
2134+ . expect ( dataGrid . getDataCells ( 0 ) . nth ( 0 ) . textContent )
2135+ . eql ( String ( targetKey ) ) ;
2136+
2137+ const visibleRows = await dataGrid . apiGetVisibleRows ( ) ;
2138+
2139+ await t . expect ( visibleRows [ 0 ] . key ) . eql ( targetKey , `Row with key ${ targetKey } should be the first visible row after navigation` ) ;
2140+ } ) . before ( async ( t ) => {
2141+ const initStore = ClientFunction ( ( ) => {
2142+ const getItems = ( ) : Record < string , unknown > [ ] => {
2143+ const items : Record < string , unknown > [ ] = [ ] ;
2144+ for ( let i = 0 ; i < 1000000 ; i += 1 ) {
2145+ items . push ( {
2146+ ID : i + 1 ,
2147+ Name : `Name ${ i + 1 } ` ,
2148+ Description : `Text text text text text text text text text text ${ i + 1 } ` ,
2149+ } ) ;
2150+ }
2151+ return items ;
2152+ } ;
2153+
2154+ ( window as any ) . myStore = new ( window as any ) . DevExpress . data . ArrayStore ( {
2155+ key : 'ID' ,
2156+ data : getItems ( ) ,
2157+ } ) ;
2158+ } ) ;
2159+
2160+ await initStore . with ( { boundTestRun : t } ) ( ) ;
2161+
2162+ return createWidget ( 'dxDataGrid' , ( ) => ( {
2163+ dataSource : new ( window as any ) . DevExpress . data . CustomStore ( {
2164+ key : 'ID' ,
2165+ loadMode : 'raw' ,
2166+ load ( loadOptions ) {
2167+ return new Promise ( ( resolve ) => {
2168+ ( window as any ) . myStore . load ( loadOptions ) . done ( ( data ) => {
2169+ resolve ( data ) ;
2170+ } ) ;
2171+ } ) ;
2172+ } ,
2173+ totalCount ( ) {
2174+ return ( window as any ) . myStore . totalCount ( ) ;
2175+ } ,
2176+ } ) ,
2177+ width : 900 ,
2178+ height : 250 ,
2179+ wordWrapEnabled : true ,
2180+ showBorders : true ,
2181+ scrolling : {
2182+ mode : 'virtual' ,
2183+ rowRenderingMode : 'virtual' ,
2184+ useNative : false ,
2185+ } ,
2186+ paging : {
2187+ pageSize : 20 ,
2188+ } ,
2189+ columns : [
2190+ {
2191+ dataField : 'ID' ,
2192+ width : 90 ,
2193+ } ,
2194+ 'Name' ,
2195+ 'Description' ,
2196+ ] ,
2197+ } ) ) ;
2198+ } ) ;
0 commit comments