Skip to content

Commit

Permalink
fix(MdTable): emit selected/update event only when selected items rea…
Browse files Browse the repository at this point in the history
…lly changed (#1585)

* fix(MdTable): only emit selected / update event when selected item(s) really changed

fix #1559

* refactor(MdTable): selectedItems check changed beautify
  • Loading branch information
VdustR authored and marcosmoura committed Mar 7, 2018
1 parent 9d04824 commit a591144
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/MdTable/MdTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,28 @@
this.MdTable.hasValue = this.hasValue
}
},
'MdTable.selectedItems' (val) {
this.select(val)
'MdTable.selectedItems' (val, old) {
let changed = (() => {
let isValEmpty = !val || val.length === 0
let isOldEmpty = !old || old.length === 0
if (isValEmpty && isOldEmpty) {
return false
} else if (!isValEmpty && !isOldEmpty) {
return (val.length !== old.length) ? true : !val.every((item, index) => item == old[index])
} else {
return true
}
})()
if (changed) {
this.select(val)
}
},
'MdTable.singleSelection' (val) {
this.select(val)
'MdTable.singleSelection' (val, old) {
if (val != old) {
this.select(val)
}
},
mdSelectedValue () {
this.syncSelectedValue()
Expand Down

0 comments on commit a591144

Please sign in to comment.