From 2759ecf5b2a2b98736468ab1388f2d2e11bd6b91 Mon Sep 17 00:00:00 2001 From: msidolphin Date: Thu, 24 Mar 2022 15:20:55 +0800 Subject: [PATCH] fix(components): [el-table] cannot scroll when tableLayout is auto (#6790) * fix(components): [el-table] cannot scroll when tableLayout is auto * chore: improve code --- packages/components/table/src/table-layout.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/components/table/src/table-layout.ts b/packages/components/table/src/table-layout.ts index 6dd5276594..923f888bb2 100644 --- a/packages/components/table/src/table-layout.ts +++ b/packages/components/table/src/table-layout.ts @@ -148,18 +148,21 @@ class TableLayout { // avoid v-show return } + const { tableLayout } = this.table.props this.appendHeight.value = appendWrapper ? appendWrapper.offsetHeight : 0 - if (this.showHeader && !headerWrapper) return + if (this.showHeader && !headerWrapper && tableLayout === 'fixed') { + return + } const headerTrElm: HTMLElement = tableHeader ? tableHeader : null const noneHeader = this.headerDisplayNone(headerTrElm) - + const headerWrapperOffsetHeight = headerWrapper?.offsetHeight || 0 const headerHeight = (this.headerHeight.value = !this.showHeader ? 0 - : headerWrapper.offsetHeight) + : headerWrapperOffsetHeight) if ( this.showHeader && !noneHeader && - headerWrapper.offsetWidth > 0 && + headerWrapperOffsetHeight > 0 && (this.table.store.states.columns.value || []).length > 0 && headerHeight < 2 ) {