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.

Dropdown list items rendered multiple times when bulk adding options

See original GitHub issue

It seems that render() is called every time a choice is added and render removes all innerHTML DOM elements from the dropdown and recreates the list leading to poor performance with large sets, O(n2).

setChoices calls _addChoice in a loop which in turn calls store.dispatch and store calls render on every state change.

The pattern seems to look like: render 1 - clear - render 1, render 2 - clear render 1, render 2, render3

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
nilsschmidthamburgcommented, Dec 17, 2018

Hi there, first of all: Thanks for the great work!

I just tested the integrate-morphdom branch to see if it is beneficial for our performance problems with choichesjs. I cannot say that it solved our issues. Maybe the search and update is faster. But adding a lot (aprox. 2000 Items) via setItems on an initially empty list still takes several seconds. I didn’t have time (nor the skills) to look deeper into this, but its pretty easy to reproduce like this:

const data = [...Array(1000).keys()].map(value => ({value, label: `${value}`}));

    // Pretty fast
    new Choices(element, {choices: data});

    // Very, very slow
    new Choices(element).setChoices(data);
1reaction
flying-sheepcommented, Mar 28, 2019

@stale no

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select2 performance for large set of items - Stack Overflow
The huge list of options doesn't show until the user has typed a couple of characters. This greatly reduces the performance hit while...
Read more >
Insert a multiple-selection list box - Microsoft Support
A multiple-selection list box is list of choices that looks like a scrollable list of check boxes ... Enable users to select multiple...
Read more >
Angular: Binding dropdown with huge data set | Coding In Depth
So when data increases, i.e. 10,000 plus dataset. The dropdown is so slow it takes a few seconds to open and render each...
Read more >
Rendering large lists in React: 5 methods with examples
Lists are an integral part of most web applications because they help display data in a more presentable format. But, when an app...
Read more >
Edit multiple records in a list using the list editor
To select multiple non-consecutive fields, press Shift and click in one of the desired fields, then hold Shift + Ctrl (Shift + Command...
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