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