Skip to content

Commit ba94e92

Browse files
cs1707cn3lfs
authored andcommitted
Table: revert sync fixed table rows height (ElemeFE#21486)
1 parent 8c995ad commit ba94e92

File tree

5 files changed

+13
-77
lines changed

5 files changed

+13
-77
lines changed

packages/table/src/store/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ Watcher.prototype.mutations = {
9898
}
9999

100100
this.updateTableScrollY();
101-
this.syncFixedTableRowHeight();
102101
},
103102

104103
filterChange(states, options) {
@@ -112,7 +111,6 @@ Watcher.prototype.mutations = {
112111
}
113112

114113
this.updateTableScrollY();
115-
this.syncFixedTableRowHeight();
116114
},
117115

118116
toggleAllSelection() {
@@ -146,8 +144,4 @@ Watcher.prototype.updateTableScrollY = function() {
146144
Vue.nextTick(this.table.updateScrollY);
147145
};
148146

149-
Watcher.prototype.syncFixedTableRowHeight = function() {
150-
Vue.nextTick(() => this.table.layout.syncFixedTableRowHeight());
151-
};
152-
153147
export default Watcher;

packages/table/src/table-body.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,13 @@ export default {
4141
border="0">
4242
<colgroup>
4343
{
44-
this.columns
45-
.filter((column, index) => !(this.columnsHidden[index] && this.fixed))
46-
.map(column => <col name={column.id} key={column.id} />)
44+
this.columns.map(column => <col name={column.id} key={column.id} />)
4745
}
4846
</colgroup>
4947
<tbody>
5048
{
5149
data.reduce((acc, row) => {
52-
const isSelected = this.store.isSelected(row);
53-
const isExpanded = this.store.states.expandRows.indexOf(row) > -1;
54-
return acc.concat(this.wrappedRowRender({
55-
row,
56-
$index: acc.length,
57-
isSelected,
58-
isExpanded
59-
}));
50+
return acc.concat(this.wrappedRowRender(row, acc.length));
6051
}, [])
6152
}
6253
<el-tooltip effect={this.table.tooltipEffect} placement="top" ref="tooltip" content={this.tooltipContent}></el-tooltip>
@@ -329,18 +320,8 @@ export default {
329320
table.$emit(`row-${name}`, row, column, event);
330321
},
331322

332-
getRowHeight(rowKey) {
333-
const { fixed } = this;
334-
if (!fixed) {
335-
return null;
336-
}
337-
const height = (this.tableLayout.fixedColumnsBodyRowsHeight || {})[rowKey];
338-
return typeof height === 'number' ? `${height}px` : height;
339-
},
340-
341-
rowRender({ row, $index, treeRowData, isSelected, isExpanded }) {
323+
rowRender(row, $index, treeRowData) {
342324
const { treeIndent, columns, firstDefaultColumnIndex } = this;
343-
344325
const rowClasses = this.getRowClass(row, $index);
345326
let display = true;
346327
if (treeRowData) {
@@ -352,14 +333,9 @@ export default {
352333
let displayStyle = display ? null : {
353334
display: 'none'
354335
};
355-
const height = this.getRowHeight($index);
356-
const heightStyle = height ? {
357-
height
358-
} : null;
359-
360336
return (
361337
<TableRow
362-
style={[displayStyle, this.getRowStyle(row, $index), heightStyle]}
338+
style={[displayStyle, this.getRowStyle(row, $index)]}
363339
class={rowClasses}
364340
key={this.getKeyOfRow(row, $index)}
365341
nativeOn-dblclick={($event) => this.handleDoubleClick($event, row)}
@@ -382,21 +358,21 @@ export default {
382358
getCellClass={this.getCellClass}
383359
handleCellMouseEnter={this.handleCellMouseEnter}
384360
handleCellMouseLeave={this.handleCellMouseLeave}
385-
isSelected={isSelected}
386-
isExpanded={isExpanded}
361+
isSelected={this.store.isSelected(row)}
362+
isExpanded={this.store.states.expandRows.indexOf(row) > -1}
387363
fixed={this.fixed}
388364
>
389365
</TableRow>
390366
);
391367
},
392368

393-
wrappedRowRender({ row, $index, isSelected, isExpanded }) {
369+
wrappedRowRender(row, $index) {
394370
const store = this.store;
395371
const { isRowExpanded, assertRowKey } = store;
396372
const { treeData, lazyTreeNodeMap, childrenColumnName, rowKey } = store.states;
397373
if (this.hasExpandColumn && isRowExpanded(row)) {
398374
const renderExpanded = this.table.renderExpanded;
399-
const tr = this.rowRender({ row, $index, isSelected, isExpanded });
375+
const tr = this.rowRender(row, $index);
400376
if (!renderExpanded) {
401377
console.error('[Element Error]renderExpanded is required.');
402378
return tr;
@@ -429,7 +405,7 @@ export default {
429405
treeRowData.loading = cur.loading;
430406
}
431407
}
432-
const tmp = [this.rowRender({ row, $index, treeRowData, isSelected, isExpanded })];
408+
const tmp = [this.rowRender(row, $index, treeRowData)];
433409
// 渲染嵌套数据
434410
if (cur) {
435411
// currentRow 记录的是 index,所以还需主动增加 TreeTable 的 index
@@ -463,7 +439,7 @@ export default {
463439
}
464440
}
465441
i++;
466-
tmp.push(this.rowRender({ row: node, $index: $index + i, treeRowData: innerTreeRowData, isSelected, isExpanded }));
442+
tmp.push(this.rowRender(node, $index + i, innerTreeRowData));
467443
if (cur) {
468444
const nodes = lazyTreeNodeMap[childKey] || node[childrenColumnName];
469445
traverse(nodes, cur);
@@ -477,7 +453,7 @@ export default {
477453
}
478454
return tmp;
479455
} else {
480-
return this.rowRender({ row, $index, isSelected, isExpanded });
456+
return this.rowRender(row, $index);
481457
}
482458
}
483459
}

packages/table/src/table-layout.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class TableLayout {
2525
this.bodyHeight = null; // Table Height - Table Header Height
2626
this.fixedBodyHeight = null; // Table Height - Table Header Height - Scroll Bar Height
2727
this.gutterWidth = scrollbarWidth();
28-
this.fixedColumnsBodyRowsHeight = {};
2928

3029
for (let name in options) {
3130
if (options.hasOwnProperty(name)) {
@@ -114,40 +113,10 @@ class TableLayout {
114113

115114
const noData = !(this.store.states.data && this.store.states.data.length);
116115
this.viewportHeight = this.scrollX ? tableHeight - (noData ? 0 : this.gutterWidth) : tableHeight;
117-
setTimeout(() => {
118-
this.syncFixedTableRowHeight();
119-
});
120116
this.updateScrollY();
121117
this.notifyObservers('scrollable');
122118
}
123119

124-
syncFixedTableRowHeight() {
125-
const fixedColumns = this.store.states.fixedColumns;
126-
const rightFixedColumns = this.store.states.rightFixedColumns;
127-
if (fixedColumns.length + rightFixedColumns.length === 0) {
128-
return;
129-
}
130-
const { bodyWrapper } = this.table.$refs;
131-
const tableRect = bodyWrapper.getBoundingClientRect();
132-
133-
if (tableRect.height !== undefined && tableRect.height <= 0) {
134-
return;
135-
}
136-
const bodyRows = bodyWrapper.querySelectorAll('.el-table__row') || [];
137-
138-
const fixedColumnsBodyRowsHeight = [].reduce.call(
139-
bodyRows,
140-
(acc, row, index) => {
141-
const height =
142-
row.getBoundingClientRect().height || 'auto';
143-
acc[index] = height;
144-
return acc;
145-
},
146-
{}
147-
);
148-
this.fixedColumnsBodyRowsHeight = fixedColumnsBodyRowsHeight;
149-
};
150-
151120
headerDisplayNone(elm) {
152121
if (!elm) return true;
153122
let headerChild = elm;

packages/table/src/table-row.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ export default {
3939
<tr>
4040
{
4141
columns.map((column, cellIndex) => {
42-
if (columnsHidden[cellIndex] && this.fixed) {
43-
return null;
44-
}
4542
const { rowspan, colspan } = this.getSpan(row, column, $index, cellIndex);
4643
if (!rowspan || !colspan) {
4744
return null;

packages/table/src/table.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
:row-class-name="rowClassName"
116116
:row-style="rowStyle"
117117
:style="{
118-
width: layout.fixedWidth ? layout.fixedWidth + 'px' : ''
118+
width: bodyWidth
119119
}">
120120
</table-body>
121121
<div
@@ -176,7 +176,7 @@
176176
:row-style="rowStyle"
177177
:highlight="highlightCurrentRow"
178178
:style="{
179-
width: layout.rightFixedWidth ? layout.rightFixedWidth + 'px' : '',
179+
width: bodyWidth
180180
}">
181181
</table-body>
182182
<div

0 commit comments

Comments
 (0)