algolia / vue-instantsearch

👀 Algolia components for building search UIs with Vue.js
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue
MIT License
853 stars 157 forks source link

Using multiple templates/slots on searchbox doesn't work #1074

Closed eugenevk closed 3 years ago

eugenevk commented 3 years ago

Bug 🐞 I have this code:

<div class="searchbox">
   <ais-search-box placeholder="">
      <template v-slot:submit-icon>🔎</template>
      <template v-slot="{ currentRefinement, isSearchStalled, refine }">
         <input
            type="search"
            :value="currentRefinement"
            @input="refine($event.currentTarget.value)"
         >
         <span :hidden="!isSearchStalled">Loading...</span>
      </template>
   </ais-search-box>
</div>

This results in this searchbox:

image

which is not showing the submit icon, nor formats the searchbox as the default one:

image

See https://codesandbox.io/s/pedantic-rain-4fzfr?file=/src/App.vue

Haroenv commented 3 years ago

The default slot overrides everything, there's no slot to override only the input

eugenevk commented 3 years ago

Hi @Haroenv, I don't fully understand your comment. Can you elaborate?

Haroenv commented 3 years ago

The slot you're passing "default" overrides the complete DOM of the search box. As the icon is part of the complete DOM, also passing that slot will no longer have an effect, unless you render it manually inside your default slot. You can see this too if you pass either the item slot or the default slot for ais-hits

eugenevk commented 3 years ago

Thanks for the explanation.