-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: DropdownMenu(Trigger) will be slow to display when there's a lot of render elements #296
Comments
@sadeghbarati I can get this issue to working process, ok? |
@romanhrynevych absolutely 💯 ❤️ |
First of all we need to clarify that amount of elements 1000 is a big number, so I think you need to use vue-virtual-scroller This package only renders some elements near your scroll position, not all, I think that this might fix your error at all. I tried to make a demo and received some errors with table elements and library, but will send you link when something will happens 🙂 Don't think that this issue is legit for this package, maybe we will add one more example of BigData scroll after successful implementation 😁 |
I followed @hrynevychroman advice about vue-virtual-scroller. Things i want to point out first: The virtual scroller docs are poorly written, so you might get into some issues. Also another issue was about virtual scroller bad docs, and found this solution: Akryum/vue-virtual-scroller#865 the final result is this: <ClientOnly>
<div class="mb-16 flex flex-wrap items-baseline">
<DropdownMenu>
<DropdownMenuTrigger>Country</DropdownMenuTrigger>
<DropdownMenuContent
:avoidCollisions="true"
side="bottom"
align="start"
>
<DropdownMenuLabel>
<div @keydown="($event) => $event.stopPropagation()">
<JInput
v-model="searchQuery"
placeholder="Search country"
class="w-full"
id="query-country"
name="search"
>
<template #icon>
<component
:is="SearchIcon"
class="size-4 text-muted-foreground ml-1.5"
/>
</template>
</JInput>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<div class="flex py-2 flex-col">
<div class="flex px-2 items-center">
<Map class="size-4" />
<div class="ml-4">Current Location</div>
</div>
<DropdownMenuItem>{{ getSelected }}</DropdownMenuItem>
</div>
<DropdownMenuSeparator />
<DynamicScroller
:items="filteredCountries"
:min-item-size="10"
class="max-h-48 overflow-y-auto"
key-field="country_code"
>
<template v-slot="{ item, index, active }">
<DynamicScrollerItem
:item="item"
:active="active"
:size-dependencies="[item.name]"
:data-index="index"
:index="index"
:key="item.country_code"
>
<DropdownMenuItem
:key="`${item.country_code}-${index}`"
@click="selected_country = item.country_code"
>
{{ item.name }}
</DropdownMenuItem>
</DynamicScrollerItem>
</template>
</DynamicScroller>
</DropdownMenuContent>
</DropdownMenu>
</div>
</ClientOnly> |
Environment
Link to minimal reproduction
https://github.com/frankchen211/shadcn-vue/tree/draft/blue-violet
Steps to reproduce
For task page example,
View
button to open the dropdown menu, it will take a while to display(remove any functions from TanStack Table).Describe the bug
For task page example, if you have large dataset to display at one page,
like 1000 per/page, then click
View
button to open the dropdown menu, it will take a while to display, but the FacetedFilter(using Popover) is faster.Expected behavior
Faster
Conext & Screenshots (if applicable)
No response
The text was updated successfully, but these errors were encountered: