KazanExpress / vue-simple-suggest

Feature-rich autocomplete component for Vue.js
https://kazanexpress.github.io/vue-simple-suggest/
MIT License
461 stars 74 forks source link

@click listener within misc-item slot #480

Open tobyj opened 3 years ago

tobyj commented 3 years ago

I'm submitting a ...

What is the current behavior?

Unable to get @click listeners to work within misc-item-* slots. When clicking there it just closes the list. I've tried @click.stop and prevent here also. I've got around it by using hacky @focus.stop="myMethod" instead.

Is there a way to listen to clicks within misc-item slots?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

<div slot="misc-item-below">
   <div @click="enterManually">Enter address manually</div>
</div>

...

methods: {
  enterManually () {
    console.log('click event worked');
  }
}

What is the expected behavior?

Click handler should fire. List closing etc. can be done in handler.

How are you importing Vue-simple-suggest?

What is the motivation / use case for changing the behavior?

I'm using vue-simple-suggest to search addresses (similar to google maps autocomplete). If an address can't be found after a few keystrokes I need show an option to switch to a manual address input form.

Please tell us about your environment:

xlcrr commented 3 years ago

Same problem for me, custom template closes.

<template slot="misc-item-above" slot-scope="{ suggestions, query }" v-if="newItem.length > 0">
    <div v-show="suggestions.length === 0" @click="submit">
        <p class="misc-select">{{ newItem }} : click to create</p>
    </div>
</template>
kieaiaarh commented 2 years ago

@tobyj

hacky @focus.stop="myMethod" instead.

I'm having trouble with the same problem right now. If you don't mind, can you tell me exactly how to do it?