autocomplete icon indicating copy to clipboard operation
autocomplete copied to clipboard

Group results

Open nfq opened this issue 4 years ago • 3 comments

Is there a way to group results?

For instance, our site has two main 'feeds' coming from the API: Pages and News entries. I'd like to visually render them like this (mockup below)

Group-results

Any conceivable way to render something like this?

nfq avatar Jul 11 '20 23:07 nfq

Is this using the Vue or JS component?

trevoreyre avatar Jul 21 '20 19:07 trevoreyre

The JS component!

nfq avatar Jul 21 '20 21:07 nfq

Honestly, I don't think there's a really great solution to this in the JS component. You can use the renderResult option to additionally render some grouping styles, but you'll have to find some way to store the condition for rendering the group outside of the autocomplete component, and check it in the renderResult function.

Here's a simple example that just renders a new group after every 3 results. https://codepen.io/trevoreyre/pen/JjGxLEm

trevoreyre avatar Jul 22 '20 16:07 trevoreyre