mirror of
https://github.com/element-plus/element-plus.git
synced 2025-04-12 16:40:36 +08:00
fix(components): [table] use isEqual to determine whether it is selected (#17885)
* fix(components): [table] use isEqual to determine whether it is selected closed #10199, #10263 * test: add test * test: add test
This commit is contained in:
parent
8fd40c900c
commit
ae8328fb9c
@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import { nextTick, ref } from 'vue'
|
||||
import { nextTick } from 'vue'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import ElCheckbox from '@element-plus/components/checkbox'
|
||||
import triggerEvent from '@element-plus/test-utils/trigger-event'
|
||||
@ -1804,10 +1804,10 @@ describe('Table.vue', () => {
|
||||
</el-table>
|
||||
`,
|
||||
data() {
|
||||
const treeProps = ref({
|
||||
const treeProps = {
|
||||
children: 'childrenTest',
|
||||
checkStrictly: false,
|
||||
})
|
||||
}
|
||||
const testData = getTestData() as any
|
||||
testData[1].childrenTest = [
|
||||
{
|
||||
@ -1849,6 +1849,12 @@ describe('Table.vue', () => {
|
||||
wrapper.findAll('.el-checkbox')[2].trigger('click')
|
||||
await doubleWait()
|
||||
expect(wrapper.vm.selected.length).toEqual(1)
|
||||
expect(wrapper.findAll('.el-checkbox')[2].classes()).include('is-checked')
|
||||
|
||||
wrapper.findAll('.el-checkbox')[3].trigger('click')
|
||||
await doubleWait()
|
||||
expect(wrapper.vm.selected.length).toEqual(2)
|
||||
expect(wrapper.findAll('.el-checkbox')[3].classes()).include('is-checked')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import { getCurrentInstance, ref, toRefs, unref, watch } from 'vue'
|
||||
import { isEqual } from 'lodash-unified'
|
||||
import { hasOwn } from '@element-plus/utils'
|
||||
import {
|
||||
getColumnById,
|
||||
@ -149,7 +150,7 @@ function useWatcher<T>() {
|
||||
|
||||
// 选择
|
||||
const isSelected = (row) => {
|
||||
return selection.value.includes(row)
|
||||
return selection.value.some((item) => isEqual(item, row))
|
||||
}
|
||||
|
||||
const clearSelection = () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user