diegoazh / gmap-vue

A wrapper component for consuming Google Maps API built on top of Vue. Fork of the popular vue-google-maps plugin.
https://diegoazh.github.io/gmap-vue/
168 stars 49 forks source link

Bug: Autocomplete slot #328

Open drewzb opened 2 weeks ago

drewzb commented 2 weeks ago

Please complete all sections that you can but please don't remove any section, otherwise the bot will close your issue because it doesn't meet our issue template (you can remove this comment)

Describe the bug

When using a template slot in Autocomplete, there is an error that template ref 'gmvAutoCompleteInput' can't be found, or we can't use slotRef prop.

To reproduce

<GmvAutocomplete>
  <template #default="slotProps">
    <input ref="input" v-bind:attrs="slotProps.attrs" />
  </template>
</GmvAutocomplete>

Expected behavior

I would expect the to be used.

Current behavior

I'm getting an error:

autocomplete-input-ssE2hgis-VLDTRTOF.js?v=e2557f2c:64 Uncaught (in promise) Error: we can find the template ref: 'gmvAutoCompleteInput' or we can't use the slotRef prop at autocomplete-input-ssE2hgis-VLDTRTOF.js?v=e2557f2c:64:17

Screenshots

None

Desktop (please complete the following information)

Smartphone (please complete the following information)

N/A

Additional context

I've tried many other things such as changing the ref="input", remove it, adding slot-ref-name,...nothing seems to work.

Versions

Package manager

Plugin version

I'm using @gmap-vue/v3 - 2.1.2

drewzb commented 2 weeks ago

After poking around the source code, I found a workaround. Create a :slotRef that points to the template ref.

<GmvAutocomplete :slotRef="input ">
  <template #default="slotProps">
    <input ref="input" v-bind:attrs="slotProps.attrs" />
  </template>
</GmvAutocomplete>
...
const input = ref(null)
create-issue-branch[bot] commented 2 weeks ago

Branch issue-328-Bug_Autocomplete_slot created!