nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
3.57k stars 420 forks source link

A way to not filter options in InputMenu and SelectMenu #1919

Open adrianogiannacco opened 1 week ago

adrianogiannacco commented 1 week ago

Description

Hello, on our BE we have a geodata endpoint which already makes all the filtering and searches behind the curtain, with the query payload it receives. In our objects we don't have a specific field that is gonna contain the exact string that the component is passing, so, even if the options are populated correctly, the computed filteredOptions remains empty. My question is: Is there a way to not use the filteredOptions computed and just rely on the options array just as it is? Please let me know if I wasn't clear enough

noook commented 1 week ago

Yes sure ! You can just use the search prop. This prop is a function, and the return values will be the options given to those components.

Edit: I just understood you already took a look at the source code.

I think a way to allow this is by using the same condition used a few lines above in the computedAsync property: if (props.search && debouncedSearch) return options.value

https://github.com/nuxt/ui/blob/4c0a3d8dc0726327b8b8732945c722e7e02309fc/src/runtime/components/forms/InputMenu.vue#L403-L407

adrianogiannacco commented 1 week ago

Thank you very much for your answer. Not sure this will help me though, as I'm passing the options (fetched in the parent component) as props to UInputMenu

noook commented 1 week ago

I'm not sure to understand your usage of InputMenu then. Could you elaborate and provide an example ?

xMorthi commented 1 week ago

maybe command pallete is the component you are looking for? https://ui.nuxt.com/components/command-palette