Skip to content

Commit dbd2a22

Browse files
committed
fix: Not show scrollbar when out of virtual
1 parent 56c4eb1 commit dbd2a22

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/List.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
238238
let componentStyle: React.CSSProperties = null;
239239
if (height) {
240240
componentStyle = { [fullHeight ? 'height' : 'maxHeight']: height, ...ScrollStyle };
241-
componentStyle.overflowY = 'hidden';
241+
242+
if (inVirtual) {
243+
componentStyle.overflowY = 'hidden';
244+
}
242245
}
243246

244247
return (
@@ -266,14 +269,16 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
266269
</Filler>
267270
</Component>
268271

269-
<ScrollBar
270-
prefixCls={prefixCls}
271-
scrollTop={scrollTop}
272-
height={height}
273-
scrollHeight={scrollHeight}
274-
count={mergedData.length}
275-
onScroll={onScrollBar}
276-
/>
272+
{inVirtual && (
273+
<ScrollBar
274+
prefixCls={prefixCls}
275+
scrollTop={scrollTop}
276+
height={height}
277+
scrollHeight={scrollHeight}
278+
count={mergedData.length}
279+
onScroll={onScrollBar}
280+
/>
281+
)}
277282
</div>
278283
);
279284
}

tests/scroll.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,11 @@ describe('List.Scroll', () => {
135135

136136
expect(wrapper.find('ul').instance().scrollTop > 10).toBeTruthy();
137137
});
138+
139+
it('not show scrollbar when not match virtual', () => {
140+
const listRef = React.createRef();
141+
const wrapper = genList({ itemHeight: 20, height: 100, data: genData(5), ref: listRef });
142+
expect(wrapper.find('.rc-virtual-list-scrollbar-thumb')).toHaveLength(0);
143+
});
138144
});
139145
});

0 commit comments

Comments
 (0)