Skip to content

Commit 1f9606a

Browse files
authored
fix: virtual list prefixCls not working (#1082)
* fix: virtual list prefixCls not working * chore: update unit test typo
1 parent 9103b81 commit 1f9606a

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

docs/examples/virtual.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const Demo = () => {
230230
getContainerWidth={(ele, width) => {
231231
// Minus border
232232
const borderWidth = getComputedStyle(
233-
ele.querySelector('.rc-virtual-list'),
233+
ele.querySelector('.rc-table-tbody'),
234234
).borderInlineStartWidth;
235235
const mergedWidth = width - parseInt(borderWidth, 10);
236236

src/VirtualTable/BodyGrid.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
219219
<VirtualList<FlattenData<any>>
220220
fullHeight={false}
221221
ref={listRef}
222+
prefixCls={`${tblPrefixCls}-virtual`}
222223
styles={{ horizontalScrollBar: horizontalScrollBarStyle }}
223-
className={classNames(tblPrefixCls, `${tblPrefixCls}-virtual`)}
224+
className={tblPrefixCls}
224225
height={scrollY}
225226
itemHeight={listItemHeight || 24}
226227
data={flattenData}

tests/Virtual.spec.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('Table.Virtual', () => {
109109

110110
await waitFakeTimer();
111111

112-
expect(container.querySelector('.rc-virtual-list')).toBeTruthy();
112+
expect(container.querySelector('.rc-table-tbody-virtual')).toBeTruthy();
113113
});
114114

115115
it('warning for scroll props is not a number', () => {
@@ -198,7 +198,7 @@ describe('Table.Virtual', () => {
198198
scrollLeftCalled = false;
199199
expect(scrollLeftCalled).toBeFalsy();
200200

201-
fireEvent.wheel(container.querySelector('.rc-virtual-list-holder')!, {
201+
fireEvent.wheel(container.querySelector('.rc-table-tbody-virtual-holder')!, {
202202
deltaX: 10,
203203
});
204204
expect(scrollLeftCalled).toBeTruthy();
@@ -221,7 +221,10 @@ describe('Table.Virtual', () => {
221221
data: [{}],
222222
});
223223

224-
expect(container.querySelector('.rc-virtual-list')).toHaveAttribute('data-scroll-width', '603');
224+
expect(container.querySelector('.rc-table-tbody-virtual')).toHaveAttribute(
225+
'data-scroll-width',
226+
'603',
227+
);
225228
});
226229

227230
it('render params should correct', () => {
@@ -276,7 +279,7 @@ describe('Table.Virtual', () => {
276279
data: [{}],
277280
});
278281

279-
expect(container.querySelector('.rc-virtual-list')).toHaveAttribute(
282+
expect(container.querySelector('.rc-table-tbody-virtual')).toHaveAttribute(
280283
'data-scroll-width',
281284
'1128',
282285
);
@@ -303,7 +306,7 @@ describe('Table.Virtual', () => {
303306

304307
await waitFakeTimer();
305308

306-
expect(container.querySelector('.rc-virtual-list-scrollbar-horizontal')).toHaveStyle({
309+
expect(container.querySelector('.rc-table-tbody-virtual-scrollbar-horizontal')).toHaveStyle({
307310
position: 'sticky',
308311
bottom: '10px',
309312
});
@@ -420,7 +423,7 @@ describe('Table.Virtual', () => {
420423
await waitFakeTimer();
421424

422425
expect(container.querySelector('thead th')).toHaveAttribute('data-mark', 'my-th');
423-
expect(container.querySelector('.rc-virtual-list-holder')).toHaveAttribute(
426+
expect(container.querySelector('.rc-table-tbody-virtual-holder')).toHaveAttribute(
424427
'data-mark',
425428
'my-wrapper',
426429
);

0 commit comments

Comments
 (0)