question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slot outside the autosuggest_results div

See original GitHub issue

First of all, thanks for your amazing work, the component works like a charm. I’m using the 2.0.4 version and I’m trying to render a link to see more results when the amount of them exceeds the limit that I’ve configured. For this purpose, I’ve used the after-suggestions slot, and it works properly.

The problem comes when I set a max-height for the results container:

.autosuggest__results {
  max-height: 500px
  overflow: scroll;
}

The after-suggestions slot is rendered after the <ul> but inside the <div class="autosuggest__results"> so is not possible to make it visible (without scrolling) when the results exceed the max-height configured. I’ve tried to add the max-height and overflow properties to the <ul> directly, but this breaks the keyboard navigation. I would like to be able to have a See more link always visible (when there are more available results) without scrolling the list.

Here you could see an example in codebox.

So, the question is: Is there a way to position a slot just after the autosuggest_results container? If not, it would be possible to move the existing after-suggestions slot outside it? Do you think that it makes sense?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
darrenjenningscommented, Jan 7, 2020

@vlledo I added the slot you suggested, but I don’t know if it makes sense to hide/show it based on the results for all users, if you think about potentially users want some html inside the component div structure itself… but if you wanted, you can capture the value yourself and v-if on the slot using shouldRenderSuggestions like so: https://codesandbox.io/s/vueautosuggest-issue-162-bz1qw

I also updated the codesandbox to use the ensureItemVisible from the component so you don’t have to write it yourself. Thanks for the feedback!

1reaction
vlledocommented, Jan 7, 2020

Ok, that’s perfect! Thanks a lot for your support 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Only show slot if it has content
My solution was to make a generic slot component that just rendered out a slot with a surrounding div...see below.
Read more >
vue-autosuggest | Yarn - Package Manager
This slot will be overridden when the render-suggestion prop is used. Props. Prop, Type, Required, Description. suggestions, Array ...
Read more >
Using Slots In Vue.js
Slots are a powerful tool for creating reusable components in Vue.js, though they aren't the simplest feature to understand.
Read more >
Is it possible to emit event from component inside slot #4332
the spinner should be removed when an event is emitted from a component that occupies the slot (slot child). the parent's template looks...
Read more >
Enabling the preview application for Workbench
All slots and content items must include a PreviewAnchor tag that wraps them in a div class that contains preview information. This tag...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found