Skip to content

Commit

Permalink
fix(MdTable): nextTick selection data (#1874)
Browse files Browse the repository at this point in the history
* comp(mdTable): nextTick selection data

The current implementation couldn't handle selection data and table data at the same time #1866

* comp(MdTable): also handle case #2 AOT

providing selection data Ahead of Time, aka, ahead of table data, will also break MdTable. This handles both cases.

* comp(MdTable): remove redundant nextTick

* comp(MdTable): merge glitch fix
  • Loading branch information
Ray Foss authored and Samuell1 committed Jul 26, 2018
1 parent 87f95fb commit 6fbdd21
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/MdTable/MdTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@
},
mdSelectedValue () {
this.syncSelectedValue()
},
value () {
this.syncSelectedValue()
}
},
methods: {
Expand Down Expand Up @@ -333,11 +336,13 @@
this.$emit('md-selected', val)
},
syncSelectedValue () {
if (this.MdTable.selectingMode === 'single') {
this.MdTable.singleSelection = this.mdSelectedValue
} else if (this.MdTable.selectingMode === 'multiple') {
this.MdTable.selectedItems = this.mdSelectedValue || []
}
this.$nextTick().then(() => { // render the table first
if (this.MdTable.selectingMode === 'single') {
this.MdTable.singleSelection = this.mdSelectedValue
} else if (this.MdTable.selectingMode === 'multiple') {
this.MdTable.selectedItems = this.mdSelectedValue || []
}
})
},
setWidth () {
if (this.mdFixedHeader) {
Expand All @@ -350,9 +355,7 @@
this.sortTable()
}
this.$nextTick().then(() => {
this.syncSelectedValue()
})
this.syncSelectedValue()
},
mounted () {
this.setContentEl()
Expand Down

0 comments on commit 6fbdd21

Please sign in to comment.