You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed a performance issue with the TreeSelect component when using a large dataset (more than 10K items). This issue occurs every time the user clicks on a node in the tree.
In the screenshot below, you can see the execution time on my machine. In the provided reproduction example, you will find the largeData.json file inside the src folder. This dataset was built based on real-world data from my project.
I investigated the cause of the issue and found that it occurs because of the findSelectedNodes function in the TreeSelect.vue component.
This function goes through the whole tree every time the modelValue is changed.
I fixed this issue and will prepare a pull request a bit later.
My solution is based on the strategy of building a cached key-value object where the key is node.key and the value is the node itself.
This object can be used inside the selectedNodes computed property, so no recursion is needed anymore every time when user select node.
Here is a performance comparison between my solution and the original one.
Performance was measured using the performance.mark and performance.measure APIs. nodeMap is the name of my solution, and findSelectedNodes refers to the execution performance of the findSelectedNodes function.
Describe the bug
Hello!
I noticed a performance issue with the TreeSelect component when using a large dataset (more than 10K items). This issue occurs every time the user clicks on a node in the tree.
In the screenshot below, you can see the execution time on my machine. In the provided reproduction example, you will find the
largeData.json
file inside thesrc
folder. This dataset was built based on real-world data from my project.I investigated the cause of the issue and found that it occurs because of the
findSelectedNodes
function in the TreeSelect.vue component.This function goes through the whole tree every time the
modelValue
is changed.I fixed this issue and will prepare a pull request a bit later.
My solution is based on the strategy of building a cached
key-value
object where thekey
isnode.key
and the value is thenode
itself.This object can be used inside the
selectedNodes
computed property, so no recursion is needed anymore every time when user select node.Here is a performance comparison between my solution and the original one.
Performance was measured using the
performance.mark
andperformance.measure
APIs.nodeMap
is the name of my solution, andfindSelectedNodes
refers to the execution performance of thefindSelectedNodes
function.Reproducer
https://stackblitz.com/edit/primevue-4-vite-issue-template-fiy3wg4z?file=src%2FApp.vue
PrimeVue version
4.2.4
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
Chrome 131.0.6778.108
Steps to reproduce the behavior
Expected behavior
No noticeable browser freeze every time when node was selected with large amount of children's.
The text was updated successfully, but these errors were encountered: