-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table: make toggleAllSelection method an instance method(#14075) #14146
Conversation
Deploy preview for element ready! Built with commit c927012 |
@@ -112,6 +112,35 @@ const TableStore = function(table, initialState = {}) { | |||
selectOnIndeterminate: false | |||
}; | |||
|
|||
this._toggleAllSelection = debounce(10, function(states) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.toggleAllSelection=debunce(10, this._toggleAllSelection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是为了避免每次实例化时都创建一个匿名函数吗?这里可以把传入debounce的函数声明成一个常量,这样在原型链也查找不到了。
table.$emit('select-all', selection); | ||
states.isAllSelected = value; | ||
}) | ||
toggleAllSelection(state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_toggleAllSelection(state) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
执行toggleAllSelection方法时commit的操作是toggleAllSelection
,所以TableStore.prototype.method要有一个同名方法toggleAllSelection。
@LilyWakana please move _toggleAllSelection to the prototype method |
Great work, Thank you for your contributions! |
by the way:
The best solution is: put |
got it.thank you. |
ElemeFE/element#14146 this problem led to the selection without the first to get the value closed element-plus#12887
ElemeFE/element#14146 this problem led to the selection without the first to get the value closed element-plus#12887
ElemeFE/element#14146 this problem led to the selection without the first to get the value closed element-plus#12887
ElemeFE/element#14146 this problem led to the selection without the first to get the value closed element-plus#12887
fix #14075 .
All instances of TableStore share the same toggleAllSelection method in TableStore.prototype.mutations.Since the toggleAllSelection method is a debounce function which create a closure, all TableStore's instances share the same Lexical scope while they call the toggleAllSelection method. The time interval between two tables call
toggleAllSelection
is less than the debouncing delay(10), so the first call doesn't work.This commit make the actual toggleAllSelection method an instance method.
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.