ElemeFE / ElemeFE/element

[Bug Report] table 的 toggleRowSelection 不生效

Open
#20,343 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vue
Stars
54k
Forks
14.4k
PR merge metrics
No merged PRs in 30d

Description

### Element UI version
2.13.2

### OS/Browsers version
macos

### Vue version
3.0.2

### Reproduction Link
https://jsfiddle.net/mmx38qxw/

### Steps to reproduce
对 table 进行一步分装 CustomTable 组件

然后通过 this.$refs.table.toggleRowSelection() 调用

结果不生效

关键代码在这里

https://github.com/ElemeFE/element/blob/90c5d74fd3c18f75628fc20cae4cdbad7e1591b8/packages/table/src/util.js#L198-L203

在做对比的时候使用了 `const index = statusArr.indexOf(row);`

因为封装的 table 的数据是来自 prop,对象的引用改变了。

所以 `statusArr.indexOf(row);` 永远找不到对象

所以 `toggleRowSelection` 不会生效

### What is Expected?
xxx

### What is actually happening?
xxx

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproduction link and packages/table/src/util.js at lines 198-203, then inspect how toggleRowSelection is called through the CustomTable wrapper and how its prop data is passed. Confirm the reported behavior and the intended selection result before making a change; the issue's expected and actual behavior fields are still unspecified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.