dipson88 / treeselectjs

Treeselect on vanilla JS
MIT License
83 stars 15 forks source link

Freeze screen and the select is too slow when there are big data #98

Open a-allouch-ids opened 7 months ago

a-allouch-ids commented 7 months ago

Hi, I have a scenario of tree that contains more than 6300 records, and up to 10 children levels. When collopsing/expanding a node, the screen is freezing and it is too slow (it takes more than 5 seconds sometimes). Thank you

peterchenadded commented 4 months ago

Saw this issue as well.

Looking at the source code I think there are some easy changes we can make to improve the performance as listed below:

  1. The updateDOM method is looping through all the options and uses selectorQuery to find each domElement on every call.

This should be refactored so the dom elements are cached for fast access within flattedOptions.

  1. In several places we need to go from option id to flat option and at the moment it has to loop through all the options to find it.

This should be refactored so we have a map of id to option and can quickly get a flat option to work with.

Let me know if someone would like to make the changes or want me to give it a try and raise a PR?