Browse Source

fix: remove fixed height when table virtualized (#1275)

* fix: remove fixed height when table virtualized

Co-authored-by: pointhalo <[email protected]>
YannLynn 2 years ago
parent
commit
3662f43314

+ 0 - 2
packages/semi-foundation/table/constants.ts

@@ -60,7 +60,6 @@ const DEFAULT_CELL_MIDDLE_PADDING_BOTTOM = 12;
 const DEFAULT_CELL_SMALL_PADDING_TOP = 8;
 const DEFAULT_CELL_SMALL_PADDING_BOTTOM = 8;
 const DEFAULT_CELL_LINE_HEIGHT = 20;
-const DEFAULT_EMPTYSLOT_HEIGHT = 52;
 
 // normal size
 const DEFAULT_VIRTUALIZED_ROW_HEIGHT =
@@ -119,7 +118,6 @@ const numbers = {
     DEFAULT_VIRTUALIZED_SECTION_ROW_SMALL_HEIGHT: DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT,
     DEFAULT_VIRTUALIZED_ROW_SMALL_HEIGHT,
     DEFAULT_VIRTUALIZED_ROW_SMALL_MIN_HEIGHT,
-    DEFAULT_EMPTYSLOT_HEIGHT
 } as const;
 
 export { cssClasses, strings, numbers };

+ 3 - 3
packages/semi-ui/table/Body/index.tsx

@@ -19,7 +19,7 @@ import {
     isTreeTable
 } from '@douyinfe/semi-foundation/table/utils';
 import BodyFoundation, { BodyAdapter, FlattenData, GroupFlattenData } from '@douyinfe/semi-foundation/table/bodyFoundation';
-import { strings, numbers } from '@douyinfe/semi-foundation/table/constants';
+import { strings } from '@douyinfe/semi-foundation/table/constants';
 import Store from '@douyinfe/semi-foundation/utils/Store';
 
 import BaseComponent, { BaseProps } from '../../_base/baseComponent';
@@ -424,7 +424,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
 
         const listStyle = {
             width: '100%',
-            height: virtualizedData?.length ? y : numbers.DEFAULT_EMPTYSLOT_HEIGHT,
+            height: virtualizedData?.length ? y : null,
             overflowX: 'auto',
             overflowY: 'auto',
         } as const;
@@ -440,7 +440,7 @@ class Body extends BaseComponent<BodyProps, BodyState> {
                 ref={this.listRef}
                 className={wrapCls}
                 outerRef={this.forwardRef}
-                height={listStyle.height}
+                height={virtualizedData?.length ? y : 0}
                 width={listStyle.width}
                 itemData={virtualizedData}
                 itemSize={this.itemSize}