|
9 | 9 | @click="showDropdown" |
10 | 10 | @focus="showDropdown"> |
11 | 11 | <div class="select-value"> |
12 | | - <div class="field is-grouped is-grouped-multiline" |
13 | | - v-if="multiple"> |
14 | | - <div class="control"> |
| 12 | + <div class="field is-grouped is-grouped-multiline"> |
| 13 | + <div class="control" |
| 14 | + v-if="multiple"> |
15 | 15 | <tag v-for="(option, index) in selected" |
16 | 16 | :disabled="disabled" |
17 | 17 | :label="option[label]" |
18 | 18 | :key="index" |
19 | | - @remove="remove(option);"/> |
| 19 | + @remove="remove(option[trackBy]); $emit('remove', option)"/> |
20 | 20 | </div> |
| 21 | + <input class="input select-input" type="text" |
| 22 | + v-focus |
| 23 | + :placeholder="i18n(placeholder)" |
| 24 | + v-model="query" |
| 25 | + @keydown.esc="hideDropdown" |
| 26 | + @keydown.down="keyDown" |
| 27 | + @keydown.up="keyUp" |
| 28 | + @keydown.tab="hideDropdown" |
| 29 | + @keydown.enter.prevent="hit()" |
| 30 | + v-if="dropdown"> |
21 | 31 | </div> |
22 | 32 | <span v-if="!dropdown && !(multiple && hasSelection)"> |
23 | 33 | {{ hasSelection |
24 | 34 | ? selected |
25 | 35 | : (optionList.length > 0 ? i18n(placeholder) : i18n(labels.noOptions)) |
26 | 36 | }} |
27 | 37 | </span> |
28 | | - <input class="input select-input" type="text" |
29 | | - v-focus |
30 | | - :placeholder="i18n(placeholder)" |
31 | | - v-model="query" |
32 | | - v-if="dropdown" |
33 | | - @keydown.esc="hideDropdown" |
34 | | - @keydown.down="keyDown" |
35 | | - @keydown.up="keyUp" |
36 | | - @keydown.tab="hideDropdown" |
37 | | - @keydown.enter.prevent="hit()"> |
38 | 38 | <span class="is-loading" |
39 | 39 | v-if="loading"/> |
40 | 40 | <a class="delete is-small" |
@@ -366,12 +366,10 @@ export default { |
366 | 366 | highlight(label) { |
367 | 367 | return label.replace(new RegExp(`(${this.query})`, 'gi'), '<b>$1</b>'); |
368 | 368 | }, |
369 | | - remove(option) { |
| 369 | + remove(value) { |
370 | 370 | const index = this.value |
371 | | - .findIndex(val => val === option[this.trackBy]); |
| 371 | + .findIndex(val => val === value); |
372 | 372 | this.value.splice(index, 1); |
373 | | - this.$emit('remove', option); |
374 | | - this.$emit('input', this.value); |
375 | 373 | }, |
376 | 374 | isSelected(option) { |
377 | 375 | return this.multiple |
|
0 commit comments