mirror of https://github.com/ElemeFE/element
Table: fix sort icon (#15439)
parent
5acf0101a8
commit
ef719b9652
|
@ -266,6 +266,9 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
updateSort(column, prop, order) {
|
||||
if (this.states.sortingColumn && this.states.sortingColumn !== column) {
|
||||
this.states.sortingColumn.order = null;
|
||||
}
|
||||
this.states.sortingColumn = column;
|
||||
this.states.sortProp = prop;
|
||||
this.states.sortOrder = order;
|
||||
|
|
|
@ -1753,11 +1753,47 @@ describe('Table', () => {
|
|||
vm.$nextTick(() => {
|
||||
expect(toArray(lastCells).map(node => node.textContent))
|
||||
.to.eql(['-100', '-95', '-92', '-92', '-80']);
|
||||
destroyVM(vm);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}, DELAY);
|
||||
});
|
||||
|
||||
it('sort correct change icon', async() => {
|
||||
function assertSortIconCount($el, msg, count = 1) {
|
||||
const sortIconCount = $el.querySelectorAll('th.ascending, th.descending').length;
|
||||
expect(sortIconCount).to.equal(count, msg);
|
||||
}
|
||||
|
||||
const vm = createVue({
|
||||
template: `
|
||||
<el-table ref="table" :data="testData" >
|
||||
<el-table-column prop="name" sortable />
|
||||
<el-table-column prop="release" sortable />
|
||||
<el-table-column prop="director" sortable />
|
||||
<el-table-column prop="runtime" sortable />
|
||||
</el-table>
|
||||
`,
|
||||
data() {
|
||||
return { testData: getTestData() };
|
||||
}
|
||||
});
|
||||
await waitImmediate();
|
||||
assertSortIconCount(vm.$el, 'sorting icon is not empty after mount', 0);
|
||||
// manual click first column header
|
||||
const elm = vm.$el.querySelector('.caret-wrapper');
|
||||
elm.click();
|
||||
await waitImmediate();
|
||||
assertSortIconCount(vm.$el, 'sorting icon is not one after click header');
|
||||
vm.$refs.table.sort('director', 'descending');
|
||||
await waitImmediate();
|
||||
assertSortIconCount(vm.$el, 'sorting icon is not one after call sort');
|
||||
vm.$refs.table.sort('director', 'ascending');
|
||||
await waitImmediate();
|
||||
assertSortIconCount(vm.$el, 'sorting icon is not one after sort same column');
|
||||
destroyVM(vm);
|
||||
});
|
||||
});
|
||||
|
||||
it('hover', async() => {
|
||||
|
|
Loading…
Reference in New Issue