Skip to content

Commit 887297f

Browse files
committed
not set overflow style if height is empty
1 parent 5696901 commit 887297f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/List.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import {
1313
} from './utils/itemUtil';
1414
import { getIndexByStartLoc, findListDiffIndex } from './utils/algorithmUtil';
1515

16+
const ScrollStyle = {
17+
overflowY: 'auto',
18+
overflowAnchor: 'none',
19+
};
20+
1621
type RenderFunc<T> = (
1722
item: T,
1823
index: number,
@@ -437,22 +442,22 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
437442
...restProps
438443
} = this.props;
439444

440-
const mergedStyle = {
441-
...style,
442-
height,
443-
overflowY: 'auto',
444-
overflowAnchor: 'none',
445-
};
446-
447445
// Render pure list if not set height or height is enough for all items
448446
if (height === undefined || data.length * itemHeight <= height) {
449447
return (
450-
<Component style={mergedStyle} {...restProps}>
448+
<Component style={height ? { ...style, ...ScrollStyle } : style} {...restProps}>
451449
<Filler height={height}>{this.renderChildren(data, 0, children)}</Filler>
452450
</Component>
453451
);
454452
}
455453

454+
// Use virtual list
455+
const mergedStyle = {
456+
...style,
457+
height,
458+
...ScrollStyle,
459+
};
460+
456461
const { status, startIndex, endIndex, startItemTop } = this.state;
457462
const contentHeight = data.length * itemHeight * ITEM_SCALE_RATE;
458463

0 commit comments

Comments
 (0)