Parcourir la source

fix: BasicTable tbody style height not refresh

lanjianrong il y a 4 ans
Parent
commit
4f8523fd7b
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  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`)
   }