Skip to content

Commit 1a2be37

Browse files
committed
fix(selectedStr): sort selected values
issue: #6
1 parent 5d059f5 commit 1a2be37

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

core/src/core.vue

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export default {
145145
}
146146
const events = {
147147
'update:model-value': ((fieldId) => (evt) => {
148-
this.selected[fieldId] = evt
148+
const selected = Array.from(evt).sort((a, b) => { return a > b ? 1 : -1 })
149+
this.selected[fieldId] = selected
149150
})(field.id)
150151
}
151152
@@ -220,7 +221,7 @@ export default {
220221
continue
221222
}
222223
const array = selected[field.id]
223-
const str = multiple.arrayToStr(this.sort(array), field)
224+
const str = multiple.arrayToStr(array, field)
224225
if (str === null) {
225226
this.error = 'invalid selection'
226227
return
@@ -229,12 +230,6 @@ export default {
229230
}
230231
this.error = ''
231232
this.$emit('update:model-value', strings.join(' '))
232-
},
233-
234-
sort (array) {
235-
const a = array.slice()
236-
a.sort((a, b) => a - b)
237-
return a
238233
}
239234
}
240235
}

0 commit comments

Comments
 (0)