fix(components): [el-table] defaultSort not working (#6322)

* fix(components): [el-table] defaultSort not working

* fix: unit test

* chore: improve code
This commit is contained in:
msidolphin 2022-03-07 16:15:54 +08:00 committed by GitHub
parent 166c5944d0
commit 43ee78563b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -749,9 +749,9 @@ describe('Table.vue', () => {
)
expect(lastCells.map((node) => node.text())).toEqual([
'80',
'92',
'92',
'95',
'92',
'92',
'100',
])
await doubleWait()

View File

@ -63,12 +63,12 @@ export default defineComponent({
const ns = useNamespace('table')
const filterPanels = ref({})
const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent!)
onMounted(() => {
nextTick(() => {
const { prop, order } = props.defaultSort
const init = true
parent?.store.commit('sort', { prop, order, init })
})
onMounted(async () => {
// Need double await, because udpateColumns is executed after nextTick for now
await nextTick()
await nextTick()
const { prop, order } = props.defaultSort
parent?.store.commit('sort', { prop, order, init: true })
})
const {
handleHeaderClick,