mirror of https://github.com/ElemeFE/element
Table: fix wrong empty block height (#16861)
parent
e9c5e469c1
commit
8b8a1a2e87
|
@ -49,10 +49,8 @@
|
||||||
v-if="!data || data.length === 0"
|
v-if="!data || data.length === 0"
|
||||||
class="el-table__empty-block"
|
class="el-table__empty-block"
|
||||||
ref="emptyBlock"
|
ref="emptyBlock"
|
||||||
:style="{
|
:style="emptyBlockStyle">
|
||||||
width: bodyWidth
|
<span class="el-table__empty-text" >
|
||||||
}">
|
|
||||||
<span class="el-table__empty-text">
|
|
||||||
<slot name="empty">{{ emptyText || t('el.table.emptyText') }}</slot>
|
<slot name="empty">{{ emptyText || t('el.table.emptyText') }}</slot>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -565,6 +563,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
emptyBlockStyle() {
|
||||||
|
if (this.data && this.data.length) return null;
|
||||||
|
let height = '100%';
|
||||||
|
if (this.layout.appendHeight) {
|
||||||
|
height = `calc(100% - ${this.layout.appendHeight}px)`;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
width: this.bodyWidth,
|
||||||
|
height
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
...mapStates({
|
...mapStates({
|
||||||
selection: 'selection',
|
selection: 'selection',
|
||||||
columns: 'columns',
|
columns: 'columns',
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
min-height: 60px;
|
min-height: 60px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -1944,6 +1944,28 @@ describe('Table', () => {
|
||||||
}, DELAY);
|
}, DELAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('table append is visible in viewport if height is 100%', async() => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-table :data="[]" height="100%">
|
||||||
|
<el-table-column prop="name" label="片名" />
|
||||||
|
<el-table-column prop="release" label="发行日期" />
|
||||||
|
<el-table-column prop="director" label="导演" />
|
||||||
|
<el-table-column prop="runtime" label="时长(分)" />
|
||||||
|
<template slot="append">
|
||||||
|
<div class="append-content" style="height: 48px;">
|
||||||
|
append 区域始终出现在视图内
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
await waitImmediate();
|
||||||
|
const emptyBlockEl = vm.$el.querySelector('.el-table__empty-block');
|
||||||
|
expect(emptyBlockEl.style.height).to.be.equal('calc(100% - 48px)');
|
||||||
|
destroyVM(vm);
|
||||||
|
});
|
||||||
|
|
||||||
describe('tree', () => {
|
describe('tree', () => {
|
||||||
let vm;
|
let vm;
|
||||||
afterEach(() => destroyVM(vm));
|
afterEach(() => destroyVM(vm));
|
||||||
|
|
Loading…
Reference in New Issue