|
7 | 7 | /> |
8 | 8 | </slot> |
9 | 9 | <q-popover ref="popover" :anchor-click="false"> |
10 | | - <div v-if="searching" class="row justify-center" :style="{minWidth: width, padding: '3px 10px'}"> |
11 | | - <spinner name="dots" :size="40"></spinner> |
12 | | - </div> |
13 | | - <div v-else class="list no-border" :class="{'item-delimiter': delimiter}" :style="computedWidth"> |
| 10 | + <div class="list no-border" :class="{'item-delimiter': delimiter}" :style="computedWidth"> |
14 | 11 | <q-list-item |
15 | 12 | v-for="(result, index) in computedResults" |
16 | 13 | :item="result" |
@@ -87,47 +84,39 @@ export default { |
87 | 84 | methods: { |
88 | 85 | trigger () { |
89 | 86 | this.width = Utils.dom.width(this.inputEl) + 'px' |
90 | | - this.$nextTick(() => { |
91 | | - const searchId = Utils.uid() |
92 | | - this.searchId = searchId |
| 87 | + const searchId = Utils.uid() |
| 88 | + this.searchId = searchId |
93 | 89 |
|
94 | | - if (this.model.length < this.minCharacters) { |
95 | | - this.searchId = '' |
96 | | - this.close() |
97 | | - return |
98 | | - } |
| 90 | + if (this.model.length < this.minCharacters) { |
| 91 | + this.searchId = '' |
| 92 | + this.close() |
| 93 | + return |
| 94 | + } |
| 95 | +
|
| 96 | + if (this.staticData) { |
| 97 | + this.searchId = '' |
| 98 | + this.results = Utils.filter(this.model, this.staticData) |
| 99 | + this.$refs.popover.open() |
| 100 | + return |
| 101 | + } |
99 | 102 |
|
100 | | - this.$refs.popover.close() |
101 | | - setTimeout(() => { |
102 | | - if (this.staticData) { |
103 | | - this.searchId = '' |
104 | | - this.results = Utils.filter(this.model, this.staticData) |
105 | | - this.$refs.popover.open() |
| 103 | + this.$emit('search', this.model, results => { |
| 104 | + if (results && this.searchId === searchId) { |
| 105 | + this.searchId = '' |
| 106 | + if (this.results === results) { |
106 | 107 | return |
107 | 108 | } |
108 | 109 |
|
109 | | - this.$refs.popover.open() |
110 | | - this.$emit('search', this.model, results => { |
111 | | - if (results && this.searchId === searchId) { |
112 | | - this.searchId = '' |
113 | | -
|
114 | | - if (Array.isArray(results) && results.length > 0) { |
115 | | - this.$refs.popover.close() |
116 | | - this.$nextTick(() => { |
117 | | - this.results = results |
118 | | - setTimeout(() => { |
119 | | - if (this.$refs && this.$refs.popover) { |
120 | | - this.$refs.popover.open() |
121 | | - } |
122 | | - }, 10) |
123 | | - }) |
124 | | - return |
125 | | - } |
126 | | -
|
127 | | - this.close() |
| 110 | + if (Array.isArray(results) && results.length > 0) { |
| 111 | + this.results = results |
| 112 | + if (this.$refs && this.$refs.popover) { |
| 113 | + this.$refs.popover.open() |
128 | 114 | } |
129 | | - }) |
130 | | - }, 10) |
| 115 | + return |
| 116 | + } |
| 117 | +
|
| 118 | + this.close() |
| 119 | + } |
131 | 120 | }) |
132 | 121 | }, |
133 | 122 | close () { |
|
0 commit comments