Dropdown/select for a huge amount of options

So I’m buildin’ a system for a company covering the whole France. I need a select/dropdown for the cities from a Supabase table (up to 39k records from the Post of the France). Now I’m using a shorted version with 8k cities but still…

  1. If I bind the collection, select element refuses to work.
  2. If I bind collection.data, it generates 8k (-25 as the size of a collection page) of null options and then tries to work, but if the value is not from the first collection page, it doesn’t work, but consumes an enormous amount of memory and CPU.

How to implement this dropdown correctly? I need to show the selected city/town and be able to find a city with the searchable item list. Onchange event should set the PC/ZIP for another field.

Hi @Antiokh :wave:

Indeed, 8k items is too many for the browser to render without slowing down significantly or crashing. This is not specific to WeWeb. You’ll need to filter and paginate your data in Supabase so it returns a reasonable number of options to render in the dropdown, preferably < 100 to keep things smooth.

So the idea is the following:

  • have a collection with a pagination that returns only a few dozen items
  • bind that collection to your dropdown options
  • as the user scrolls down the dropdown, fetch more and more items
  • when the user types in something in the search, refetch that collection with those filters

Does that make sense?

Here’s some documentation that might help with this:

EDIT: just saw your post here and it looks like you may already have tried working with paginated data. Could you record a short video showing me how things are setup on your side? I’ll try to reproduce the issue you’re facing on one of my Supabase projects and find a solution for you

1 Like

Thank you, but that’s a core of the problem. I do have Supabase filtered and paginated by 20 items but if I try to bind it to my searchable dropdown, it generates null entries for every hidden element, so I have collection.data containing of 20 elements and 8060 null elements. Of course, it slows down everything. I’ll take a look at docs you’ve attached. I guess that I’ve already familiar with those manuals.

Ok, I’ll record a video.

I think the key is to not use a collection, but use some variables and the Select Database action. There you can define your own pagination that doesn’t have a ton of null values.

Although I do wish the null values weren’t a thing, it’d be so much easier :stuck_out_tongue:

1 Like

But how should the “Search” option work? As a concept, dropdown should work with the backend collection and follow the settings of the collection (like pagination as a limit and for an infinite scroll).

Yes, we can use a “Search with suggestions” element as a workaround or create an own dropdown select control, I’m just trying to figure out, how I can utilize the standard component.

@Joyce I am also interested to see how you can apply infinity scroll or scrolled pagination on dropdown options.

1 Like

I’ve started to record a video and understood that the problem was with the collection itself as Supabase is set by default not to show more then 1000 records.

For those who will meet the same problem:

  1. You need to fetch all the elements to collection and then limit them on a frontend side.
    https://www.youtube.com/watch?v=XKq9SyTIU9c

  2. You have to change the API settings of Supabase to allow getting more then 1000 items.