Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Akbarism/fix autocomplete #87

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = {
es6: true,
node: true,
},
"globals": {
"google": true
globals: {
google: true,
},
parser: 'vue-eslint-parser',
parserOptions: {
Expand Down
7 changes: 4 additions & 3 deletions src/components/autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ export default {
// get correct input from fallback or slot
let refInput = _this.$refs.input
if (_this.$slots.input) {
const refName = _this.$slots.input()[0].props.ref
const scopedInput = _this.$slots.input()[0].ref.i.ctx.$refs[refName]
const input = _this.$slots.input().find((el) => el.props.ref == 'input')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, this line was failing, I put a comment inside the template:

<template #input="slotProps">
      <!-- Some comment  -->
      <input v-bind="slotProps" ref="input" />
  </template>

And got errors that props/ref was not defined. Could be solved by not putting comments in the template, but a better fix might be to check if the props/ref is defined:

const input = _this.$slots.input().find((el) => el?.props?.ref && el.props.ref == 'input')

const refName = input.props.ref
const scopedInput = input.ref.i.ctx.$refs[refName]
if (scopedInput) {
refInput = scopedInput.$el.getElementsByTagName('input')[0]
refInput = scopedInput
}
}
if (this.selectFirstOnEnter) {
Expand Down