Skip to content

Commit b458210

Browse files
authored
fix: scrollbar should not be displayed when scrollHeight is greater than height (#208)
1 parent 214131c commit b458210

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

src/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
372372
</Filler>
373373
</Component>
374374

375-
{useVirtual && (
375+
{useVirtual && scrollHeight > height && (
376376
<ScrollBar
377377
ref={scrollBarRef}
378378
prefixCls={prefixCls}

src/ScrollBar.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,13 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
177177
return ptg * enableHeightRange;
178178
};
179179

180-
// Not show scrollbar when height is large than scrollHeight
181-
showScroll = (): boolean => {
182-
const { height, scrollHeight } = this.props;
183-
return scrollHeight > height;
184-
};
185-
186180
// ====================== Render =======================
187181
render() {
188182
const { dragging, visible } = this.state;
189183
const { prefixCls, direction } = this.props;
190184
const spinHeight = this.getSpinHeight();
191185
const top = this.getTop();
192186

193-
const canScroll = this.showScroll();
194-
const mergedVisible = canScroll && visible;
195187
const scrollBarDirection =
196188
direction === 'rtl'
197189
? {
@@ -204,16 +196,14 @@ export default class ScrollBar extends React.Component<ScrollBarProps, ScrollBar
204196
return (
205197
<div
206198
ref={this.scrollbarRef}
207-
className={classNames(`${prefixCls}-scrollbar`, {
208-
[`${prefixCls}-scrollbar-show`]: canScroll,
209-
})}
199+
className={`${prefixCls}-scrollbar`}
210200
style={{
211201
width: 8,
212202
top: 0,
213203
bottom: 0,
214204
...scrollBarDirection,
215205
position: 'absolute',
216-
display: mergedVisible ? null : 'none',
206+
display: visible ? null : 'none',
217207
}}
218208
onMouseDown={this.onContainerMouseDown}
219209
onMouseMove={this.delayHidden}

0 commit comments

Comments
 (0)