From 6fbdd2191ac041a16e30869d8e6fcc4efd13fd33 Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Thu, 26 Jul 2018 07:33:27 -0500 Subject: [PATCH] fix(MdTable): nextTick selection data (#1874) * 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 --- src/components/MdTable/MdTable.vue | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/MdTable/MdTable.vue b/src/components/MdTable/MdTable.vue index d075588a9..c39984f40 100644 --- a/src/components/MdTable/MdTable.vue +++ b/src/components/MdTable/MdTable.vue @@ -257,6 +257,9 @@ }, mdSelectedValue () { this.syncSelectedValue() + }, + value () { + this.syncSelectedValue() } }, methods: { @@ -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) { @@ -350,9 +355,7 @@ this.sortTable() } - this.$nextTick().then(() => { - this.syncSelectedValue() - }) + this.syncSelectedValue() }, mounted () { this.setContentEl()