Skip to content

Commit

Permalink
Table: fix header table not display (#17341)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyoung authored and island205 committed Oct 31, 2019
1 parent fcaec91 commit fa7bdd4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/table/src/layout-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export default {
},

methods: {
onColumnsChange() {
onColumnsChange(layout) {
const cols = this.$el.querySelectorAll('colgroup > col');
if (!cols.length) return;
const flattenColumns = this.tableLayout.getFlattenColumns();
const flattenColumns = layout.getFlattenColumns();
const columnsMap = {};
flattenColumns.forEach((column) => {
columnsMap[column.id] = column;
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/table-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TableLayout {
if (this.showHeader && !headerWrapper) return;

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

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

headerDisplayNone(elm) {
if (!elm) return true;
let headerChild = elm;
while (headerChild.tagName !== 'DIV') {
if (getComputedStyle(headerChild).display === 'none') {
Expand Down
1 change: 1 addition & 0 deletions packages/table/src/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@
updateScrollY() {
const changed = this.layout.updateScrollY();
if (changed) {
this.layout.notifyObservers('scrollable');
this.layout.updateColumnsWidth();
}
},
Expand Down

0 comments on commit fa7bdd4

Please sign in to comment.