|
172 | 172 |
|
173 | 173 | <template>
|
174 | 174 | <div class="dropdown v-select" :class="dropdownClasses">
|
175 |
| - <div v-el:toggle @mousedown.prevent="toggleDropdown" class="dropdown-toggle clearfix" type="button"> |
| 175 | + <div ref="toggle" @mousedown.prevent="toggleDropdown" class="dropdown-toggle clearfix" type="button"> |
176 | 176 |
|
177 |
| - <span class="selected-tag" v-for="option in valueAsArray" track-by="$index"> |
| 177 | + <span class="selected-tag" v-for="(option, index) in valueAsArray" track-by="index"> |
178 | 178 | {{ getOptionLabel(option) }}
|
179 | 179 | <button v-if="multiple" @click="select(option)" type="button" class="close">
|
180 | 180 | <span aria-hidden="true">×</span>
|
181 | 181 | </button>
|
182 | 182 | </span>
|
183 | 183 |
|
184 | 184 | <input
|
185 |
| - v-el:search |
| 185 | + ref="search" |
186 | 186 | :debounce="debounce"
|
187 | 187 | v-model="search"
|
188 | 188 | @keydown.delete="maybeDeleteValue"
|
|
199 | 199 | :style="{ width: isValueEmpty ? '100%' : 'auto' }"
|
200 | 200 | >
|
201 | 201 |
|
202 |
| - <i v-el:open-indicator role="presentation" class="open-indicator"></i> |
| 202 | + <i ref="open-indicator" role="presentation" class="open-indicator"></i> |
203 | 203 |
|
204 | 204 | <slot name="spinner">
|
205 | 205 | <div class="spinner" v-show="loading">Loading...</div>
|
206 | 206 | </slot>
|
207 | 207 | </div>
|
208 | 208 |
|
209 |
| - <ul v-el:dropdown-menu v-show="open" :transition="transition" class="dropdown-menu" :style="{ 'max-height': maxHeight }"> |
210 |
| - <li v-for="option in filteredOptions" track-by="$index" :class="{ active: isOptionSelected(option), highlight: $index === typeAheadPointer }" @mouseover="typeAheadPointer = $index"> |
| 209 | + <ul ref="dropdown-menu" v-show="open" :transition="transition" class="dropdown-menu" :style="{ 'max-height': maxHeight }"> |
| 210 | + <li v-for="(option, index) in filteredOptions" track-by="index" :class="{ active: isOptionSelected(option), highlight: index === typeAheadPointer }" @mouseover="typeAheadPointer = index"> |
211 | 211 | <a @mousedown.prevent="select(option)">
|
212 | 212 | {{ getOptionLabel(option) }}
|
213 | 213 | </a>
|
214 | 214 | </li>
|
215 |
| - <li transition="fade" v-if="!filteredOptions.length" class="divider"></li> |
216 |
| - <li transition="fade" v-if="!filteredOptions.length" class="text-center"> |
217 |
| - <slot name="no-options">Sorry, no matching options.</slot> |
218 |
| - </li> |
| 215 | + <transition name="fade"> |
| 216 | + <li v-if="!filteredOptions.length" class="divider"></li> |
| 217 | + <li v-if="!filteredOptions.length" class="text-center"> |
| 218 | + <slot name="no-options">Sorry, no matching options.</slot> |
| 219 | + </li> |
| 220 | + </transition> |
219 | 221 | </ul>
|
220 | 222 | </div>
|
221 | 223 | </template>
|
|
463 | 465 | ref = val
|
464 | 466 | }
|
465 | 467 | })
|
466 |
| - this.value.$remove(ref) |
| 468 | + var index = this.value.indexOf(ref) |
| 469 | + this.value.splice(index, 1) |
467 | 470 | } else {
|
468 | 471 | this.value = null
|
469 | 472 | }
|
|
477 | 480 | onAfterSelect(option) {
|
478 | 481 | if (!this.multiple) {
|
479 | 482 | this.open = !this.open
|
480 |
| - this.$els.search.blur() |
| 483 | + this.$refs.search.blur() |
481 | 484 | }
|
482 | 485 |
|
483 | 486 | if (this.clearSearchOnSelect) {
|
|
491 | 494 | * @return {void}
|
492 | 495 | */
|
493 | 496 | toggleDropdown(e) {
|
494 |
| - if (e.target === this.$els.openIndicator || e.target === this.$els.search || e.target === this.$els.toggle || e.target === this.$el) { |
| 497 | + if (e.target === this.$refs.openIndicator || e.target === this.$refs.search || e.target === this.$refs.toggle || e.target === this.$el) { |
495 | 498 | if (this.open) {
|
496 |
| - this.$els.search.blur() // dropdown will close on blur |
| 499 | + this.$refs.search.blur() // dropdown will close on blur |
497 | 500 | } else {
|
498 | 501 | this.open = true
|
499 |
| - this.$els.search.focus() |
| 502 | + this.$refs.search.focus() |
500 | 503 | }
|
501 | 504 | }
|
502 | 505 | },
|
|
529 | 532 | */
|
530 | 533 | onEscape() {
|
531 | 534 | if (!this.search.length) {
|
532 |
| - this.$els.search.blur() |
| 535 | + this.$refs.search.blur() |
533 | 536 | } else {
|
534 | 537 | this.search = ''
|
535 | 538 | }
|
|
541 | 544 | * @return {this.value}
|
542 | 545 | */
|
543 | 546 | maybeDeleteValue() {
|
544 |
| - if (!this.$els.search.value.length && this.value) { |
| 547 | + if (!this.$refs.search.value.length && this.value) { |
545 | 548 | return this.multiple ? this.value.pop() : this.$set('value', null)
|
546 | 549 | }
|
547 | 550 | },
|
|
0 commit comments