element-plus / element-plus

🎉 A Vue.js 3 UI Library made by Element team

Home Page:https://element-plus.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Component] [table] Issue happens when listening the select-all event

lhyUnited opened this issue · comments

Bug Type: Component

Environment

  • Vue Version: 3.5.0-alpha.2
  • Element Plus Version: 2.7.2
  • Browser / OS: 124.0.6367.119 (Official Build) (x86_64)
  • Build Tool: Other

Reproduction

Related Component

  • el-table

Reproduction Link

Element Plus Playground

Steps to reproduce

Steps:

  1. Create a Table with two or more types of data and a Select to change different types of data to show.
  2. First select some items on the Food
  3. Switch to Drink types of data
  4. Select all and unselect all
  5. Switch back to Food, do nothing
  6. Switch to Drink again and check the result

What is Expected?

The select-all header-cell should be unchecked since there is no item being selected.

What is actually happening?

The select-all header-cell is selected.

Additional comments

(empty)

you can see this demo,does it meet your expectations?

Yes, it works well. But the root cause is here, table gives selection out which would cause object reference issue. The data of listeners could change unexpectedly

instance.emit('select-all', selection.value)

About PR #16800

because when selecting all and canceling, the selection is not updated again. When switching to Food, Food and Drink have the same reference.