Skip to content

Commit 488769c

Browse files
author
pablohpsilva
committed
fix on issue vuematerial#742.
1 parent 369f3f0 commit 488769c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

docs/src/pages/components/Select.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,9 @@
325325
</md-select>
326326
</md-input-container>
327327
</div>
328-
328+
329329
<div>Selected users: {{ users }}</div>
330+
330331
</div>
331332

332333
<div slot="code">

src/components/mdSelect/mdSelect.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
watch: {
6161
value(value) {
6262
this.setTextAndValue(value);
63+
this.selectOptions(value);
6364
},
6465
disabled() {
6566
this.setParentDisabled();
@@ -81,6 +82,16 @@
8182
setParentPlaceholder() {
8283
this.parentContainer.hasPlaceholder = !!this.placeholder;
8384
},
85+
selectOptions(modelValue) {
86+
const optionsArray = Object.keys(this.options).map((el) => this.options[el]);
87+
88+
if (optionsArray && optionsArray.length) {
89+
optionsArray.filter((el) => modelValue.indexOf(el.value) !== -1)
90+
.forEach((el) => {
91+
el.check = true;
92+
});
93+
}
94+
},
8495
getSingleValue(value) {
8596
let output = {};
8697
@@ -124,7 +135,9 @@
124135
return {};
125136
},
126137
setTextAndValue(modelValue) {
127-
const output = this.multiple ? this.getMultipleValue(modelValue) : this.getSingleValue(modelValue);
138+
const output = this.multiple ?
139+
this.getMultipleValue(modelValue) :
140+
this.getSingleValue(modelValue);
128141
129142
this.selectedValue = output.value;
130143
this.selectedText = output.text;

0 commit comments

Comments
 (0)