File tree 2 files changed +78
-17
lines changed
2 files changed +78
-17
lines changed Original file line number Diff line number Diff line change @@ -218,28 +218,42 @@ const Demo = () => {
218
218
219
219
< VirtualTable
220
220
virtual = { { x : true } }
221
- columns = { columns }
221
+ columns = { [
222
+ {
223
+ dataIndex : 'a' ,
224
+ width : 100 ,
225
+ className : 'a' ,
226
+ } ,
227
+ {
228
+ dataIndex : 'b' ,
229
+ width : 200 ,
230
+ } ,
231
+ {
232
+ dataIndex : 'c' ,
233
+ width : 300 ,
234
+ } ,
235
+ {
236
+ dataIndex : 'd' ,
237
+ width : 400 ,
238
+ } ,
239
+ ] }
222
240
// expandedRowRender={({ b, c }) => b || c}
223
- scroll = { { x : 1300 , y : 200 } }
241
+ scroll = { {
242
+ x : 1000 ,
243
+ y : 200 ,
244
+ } }
245
+ style = { { width : 200 } }
224
246
data = { data }
225
247
// data={[]}
226
248
rowKey = "indexKey"
227
- expandable = { {
228
- expandedRowRender : ( ) => 2333 ,
229
- columnWidth : 60 ,
230
- expandedRowClassName : ( ) => 'good-one' ,
231
- } }
249
+ // expandable={{
250
+ // expandedRowRender: () => 2333,
251
+ // columnWidth: 60,
252
+ // expandedRowClassName: () => 'good-one',
253
+ // }}
232
254
// onRow={() => ({ className: 'rowed' })}
233
255
rowClassName = "nice-try"
234
- getContainerWidth = { ( ele , width ) => {
235
- // Minus border
236
- const borderWidth = getComputedStyle (
237
- ele . querySelector ( '.rc-table-tbody' ) ,
238
- ) . borderInlineStartWidth ;
239
- const mergedWidth = width - parseInt ( borderWidth , 10 ) ;
240
-
241
- return mergedWidth ;
242
- } }
256
+ getContainerWidth = { ( ele , width ) => 200 }
243
257
ref = { tblRef }
244
258
/>
245
259
</ div >
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ describe('Table.Virtual', () => {
41
41
scrollLeft : {
42
42
get : ( ) => {
43
43
scrollLeftCalled = true ;
44
- return 100 ;
44
+ return 0 ;
45
45
} ,
46
46
set : ( ) => { } ,
47
47
} ,
@@ -443,4 +443,51 @@ describe('Table.Virtual', () => {
443
443
fireEvent . scroll ( container . querySelector ( '.rc-table-tbody-virtual-holder' ) ! ) ;
444
444
expect ( onScroll ) . toHaveBeenCalled ( ) ;
445
445
} ) ;
446
+
447
+ it ( 'horizontal virtual' , async ( ) => {
448
+ const { container } = getTable ( {
449
+ virtual : { x : true } ,
450
+ columns : [
451
+ {
452
+ width : 100 ,
453
+ className : 'a' ,
454
+ } ,
455
+ {
456
+ width : 50 ,
457
+ className : 'b' ,
458
+ } ,
459
+ {
460
+ width : 100 ,
461
+ className : 'c' ,
462
+ } ,
463
+ {
464
+ width : 50 ,
465
+ className : 'd' ,
466
+ } ,
467
+ ] ,
468
+ scroll : {
469
+ x : 300 ,
470
+ y : 10 ,
471
+ } ,
472
+ getContainerWidth : ( ) => 200 ,
473
+ data : [ { } ] ,
474
+ } ) ;
475
+
476
+ resize ( container . querySelector ( '.rc-table' ) ) ;
477
+
478
+ await waitFakeTimer ( ) ;
479
+
480
+ expect ( container . querySelector ( '.rc-table-row' ) . children . length ) . toBe ( 3 ) ;
481
+ expect ( container . querySelector ( '.rc-table-row' ) . children [ 0 ] . classList ) . toContain ( 'a' ) ;
482
+ expect ( container . querySelector ( '.rc-table-row' ) . children [ 1 ] . classList ) . toContain ( 'b' ) ;
483
+ expect ( container . querySelector ( '.rc-table-row' ) . children [ 2 ] . classList ) . toContain ( 'c' ) ;
484
+
485
+ fireEvent . wheel ( container . querySelector ( '.rc-table-tbody-virtual-holder' ) ! , {
486
+ deltaX : 100 ,
487
+ } ) ;
488
+ expect ( container . querySelector ( '.rc-table-row' ) . children . length ) . toBe ( 3 ) ;
489
+ expect ( container . querySelector ( '.rc-table-row' ) . children [ 0 ] . classList ) . toContain ( 'b' ) ;
490
+ expect ( container . querySelector ( '.rc-table-row' ) . children [ 1 ] . classList ) . toContain ( 'c' ) ;
491
+ expect ( container . querySelector ( '.rc-table-row' ) . children [ 2 ] . classList ) . toContain ( 'd' ) ;
492
+ } ) ;
446
493
} ) ;
You can’t perform that action at this time.
0 commit comments