ソースを参照

fix: BasicTable tbody style height not refresh

lanjianrong 4 年 前
コミット
4f8523fd7b
1 ファイル変更6 行追加2 行削除
  1. 6 2
      src/components/Table/src/hooks/useTableScroll.ts

+ 6 - 2
src/components/Table/src/hooks/useTableScroll.ts

@@ -32,7 +32,6 @@ export function useTableScroll({
     const { bottomIncludeBody } = getViewportOffset(headEl)
     const tableContainerEl: HTMLElement = tableElRef.current?.querySelector('.ant-table-container')
     if (!tableContainerEl) return
-
     let paddingHeight = 24
 
     let paginationHeight = 0
@@ -92,9 +91,14 @@ export function useTableScroll({
 
       tbodyEl && (tbodyEl!.style.height = notDataHeight)
       return
+    } else {
+      // TODO:有可能已经设置过tbody.ant-table-tbody要归0
+      const tbodyEl: HTMLElement = tableContainerEl?.querySelector('tbody.ant-table-tbody')
+      if (tbodyEl?.style?.height) {
+        tbodyEl.style.height = 'unset'
+      }
     }
     const tbodyEl: HTMLElement = tableContainerEl?.children[1]
-
     tbodyEl && (tbodyEl!.style.height = `${height}px`)
   }