Skip to content

Commit fa7bdd4

Browse files
ziyoungisland205
authored andcommitted
Table: fix header table not display (ElemeFE#17341)
1 parent fcaec91 commit fa7bdd4

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

packages/table/src/layout-observer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export default {
3333
},
3434

3535
methods: {
36-
onColumnsChange() {
36+
onColumnsChange(layout) {
3737
const cols = this.$el.querySelectorAll('colgroup > col');
3838
if (!cols.length) return;
39-
const flattenColumns = this.tableLayout.getFlattenColumns();
39+
const flattenColumns = layout.getFlattenColumns();
4040
const columnsMap = {};
4141
flattenColumns.forEach((column) => {
4242
columnsMap[column.id] = column;

packages/table/src/table-layout.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class TableLayout {
9797
if (this.showHeader && !headerWrapper) return;
9898

9999
// fix issue (https://github.com/ElemeFE/element/pull/16956)
100-
const headerTrElm = headerWrapper.querySelector('.el-table__header tr');
100+
const headerTrElm = headerWrapper ? headerWrapper.querySelector('.el-table__header tr') : null;
101101
const noneHeader = this.headerDisplayNone(headerTrElm);
102102

103103
const headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
@@ -119,6 +119,7 @@ class TableLayout {
119119
}
120120

121121
headerDisplayNone(elm) {
122+
if (!elm) return true;
122123
let headerChild = elm;
123124
while (headerChild.tagName !== 'DIV') {
124125
if (getComputedStyle(headerChild).display === 'none') {

packages/table/src/table.vue

+1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@
383383
updateScrollY() {
384384
const changed = this.layout.updateScrollY();
385385
if (changed) {
386+
this.layout.notifyObservers('scrollable');
386387
this.layout.updateColumnsWidth();
387388
}
388389
},

0 commit comments

Comments
 (0)