Skip to content

Commit

Permalink
fix: [Vue warn]: Injection "__inputParent" not found (QAutocomplete) q…
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Oct 20, 2017
1 parent 2399d1d commit 079eb91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dev/components/test-layout/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<q-route-tab slot="title" icon="view_quilt" to="/test-layout/about" replace hide="icon" label="About" />
<q-route-tab slot="title" icon="view_day" to="/test-layout/toolbar" replace hide="label" label="Toolbar" />
<q-route-tab slot="title" icon="view_day" to="/test-layout/tabs" replace label="Tabs" />
<q-route-tab slot="title" icon="input" to="/test-layout/drawerZZZ" replace label="Drawer" />
<q-route-tab slot="title" icon="input" to="/test-layout/drawer" replace label="Drawer" />
</q-tabs>

<q-scroll-area slot="left" style="width: 100%; height: 100%;" :thumb-style="{right: '4px', borderRadius: '5px', background: 'red', opacity: 1}">
Expand Down
27 changes: 15 additions & 12 deletions src/components/autocomplete/QAutocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
ref="popover"
:anchor-click="false"
>
<div class="list no-border" :class="{separator: separator}" :style="computedWidth">
<q-list no-border link :separator="separator" :style="computedWidth">
<q-item-wrapper
v-for="(result, index) in computedResults"
:key="result.id || JSON.stringify(result)"
:cfg="result"
link
:class="{active: selectedIndex === index}"
@click="setValue(result)"
></q-item-wrapper>
</div>
</q-list>
</q-popover>
</template>

Expand All @@ -27,7 +26,7 @@ import uid from '../../utils/uid'
import { normalizeToInterval } from '../../utils/format'
import { QInput } from '../input'
import { QPopover } from '../popover'
import { QItemWrapper } from '../list'
import { QList, QItemWrapper } from '../list'
function prevent (e) {
e.preventDefault()
Expand All @@ -39,6 +38,7 @@ export default {
components: {
QInput,
QPopover,
QList,
QItemWrapper
},
props: {
Expand All @@ -61,7 +61,10 @@ export default {
staticData: Object,
separator: Boolean
},
inject: ['__input', '__inputParent'],
inject: {
'__input': { default: null },
'__inputDebounce': { default: null }
},
data () {
return {
searchId: '',
Expand Down Expand Up @@ -125,13 +128,13 @@ export default {
this.close()
this.__input.loading = true
this.$emit('search', terms, results => {
if (!results || this.searchId !== searchId) {
if (this.searchId !== searchId) {
return
}
this.__clearSearch()
if (this.results === results) {
if (!this.results || this.results === results) {
return
}
Expand Down Expand Up @@ -160,7 +163,7 @@ export default {
this.searchId = ''
},
setValue (result) {
const suffix = this.__inputParent ? 'Parent' : ''
const suffix = this.__inputDebounce ? 'Debounce' : ''
this[`__input${suffix}`].set(this.staticData ? result[this.staticData.field] : result.value)
this.$emit('selected', result)
Expand Down Expand Up @@ -225,8 +228,8 @@ export default {
return
}
this.__input.register()
if (this.__inputParent) {
this.__inputParent.setChildDebounce(true)
if (this.__inputDebounce) {
this.__inputDebounce.setChildDebounce(true)
}
this.$nextTick(() => {
this.inputEl = this.__input.getEl()
Expand All @@ -236,8 +239,8 @@ export default {
beforeDestroy () {
this.__clearSearch()
this.__input.unregister()
if (this.__inputParent) {
this.__inputParent.setChildDebounce(false)
if (this.__inputDebounce) {
this.__inputDebounce.setChildDebounce(false)
}
if (this.inputEl) {
this.inputEl.removeEventListener('keydown', this.__handleKeypress)
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/QSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
},
provide () {
return {
__inputParent: {
__inputDebounce: {
set: val => {
if (this.value !== val) {
this.$emit('input', val)
Expand Down

0 comments on commit 079eb91

Please sign in to comment.