@@ -1485,14 +1485,13 @@ export const AsyncLoadingClientFiltering: TableStory = {
1485
1485
name : 'async client side filter loading'
1486
1486
} ;
1487
1487
1488
+ interface StarWarsItem {
1489
+ name : string ,
1490
+ height : string ,
1491
+ mass : string
1492
+ }
1488
1493
1489
1494
function AsyncServerFilterTable ( props ) {
1490
- interface Item {
1491
- name : string ,
1492
- height : string ,
1493
- mass : string
1494
- }
1495
-
1496
1495
let columns = [
1497
1496
{
1498
1497
name : 'Name' ,
@@ -1509,7 +1508,7 @@ function AsyncServerFilterTable(props) {
1509
1508
}
1510
1509
] ;
1511
1510
1512
- let list = useAsyncList < Item > ( {
1511
+ let list = useAsyncList < StarWarsItem > ( {
1513
1512
getKey : ( item ) => item . name ,
1514
1513
async load ( { signal, cursor, filterText} ) {
1515
1514
if ( cursor ) {
@@ -2197,4 +2196,67 @@ function LoadingTable() {
2197
2196
) ;
2198
2197
}
2199
2198
2199
+ function AsyncLoadOverflowWrapRepro ( ) {
2200
+ let columns = [
2201
+ { name : 'Name' , key : 'name' } ,
2202
+ { name : 'Height' , key : 'height' } ,
2203
+ { name : 'Mass' , key : 'mass' } ,
2204
+ { name : 'Birth Year' , key : 'birth_year' }
2205
+ ] ;
2206
+
2207
+ let list = useAsyncList < StarWarsItem > ( {
2208
+ async load ( { signal, cursor} ) {
2209
+ if ( cursor ) {
2210
+ cursor = cursor . replace ( / ^ h t t p : \/ \/ / i, 'https://' ) ;
2211
+ }
2212
+
2213
+ let res = await fetch (
2214
+ cursor || 'https://swapi.py4e.com/api/people/?search=' ,
2215
+ { signal}
2216
+ ) ;
2217
+ let json = await res . json ( ) ;
2218
+
2219
+ return {
2220
+ items : json . results ,
2221
+ cursor : json . next
2222
+ } ;
2223
+ }
2224
+ } ) ;
2225
+
2226
+ return (
2227
+ < TableView
2228
+ aria-label = "example async loading table"
2229
+ height = "size-3000"
2230
+ overflowMode = "wrap" >
2231
+ < TableHeader columns = { columns } >
2232
+ { ( column ) => (
2233
+ < Column align = { column . key !== 'name' ? 'end' : 'start' } >
2234
+ { column . name }
2235
+ </ Column >
2236
+ ) }
2237
+ </ TableHeader >
2238
+ < TableBody
2239
+ items = { list . items }
2240
+ loadingState = { list . loadingState }
2241
+ onLoadMore = { list . loadMore } >
2242
+ { ( item ) => (
2243
+ < Row key = { item . name } >
2244
+ { ( key ) => (
2245
+ < Cell > { `${ item [ key ] } ++++${ item [ key ] } ++++${ item [ key ] } ++++` } </ Cell >
2246
+ ) }
2247
+ </ Row >
2248
+ ) }
2249
+ </ TableBody >
2250
+ </ TableView >
2251
+ ) ;
2252
+ }
2253
+
2254
+ export const AsyncLoadOverflowWrapReproStory : TableStory = {
2255
+ render : ( args ) => < AsyncLoadOverflowWrapRepro { ...args } /> ,
2256
+ name : 'async, overflow wrap scroll jumping reproduction' ,
2257
+ parameters : { description : { data : `
2258
+ Rapidly scrolling down through this table should not cause the scroll position to jump to the top.
2259
+ ` } }
2260
+ } ;
2261
+
2200
2262
export { Performance } from './Performance' ;
0 commit comments