Skip to content
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

MultiSelect: Very long selection time due to Chips #3380

Closed
arielkuzminski opened this issue Dec 7, 2022 · 3 comments
Closed

MultiSelect: Very long selection time due to Chips #3380

arielkuzminski opened this issue Dec 7, 2022 · 3 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@arielkuzminski
Copy link

Describe the bug

Hello.
For some reason MultiSelect takes very long time to select all items in list or even single select when lots of items are already selected.
I did a "Performance" benchmark and I think issue is in deepEquals function used by PrimeVue, although I may be wrong.
image
image

Reproducer

https://codesandbox.io/s/primevue-multiselect-long-selection-time-stwzeq?file=/src/MultiSelectDemo.vue

PrimeVue version

3.20

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

  1. Open CodePens MultiSelectDemo.vue file
  2. Open MultiSelect component and click Checkbox for selecting all items.
  3. Depending on your CPU, selection will take about 5 - 20 seconds, or even in bad case browser tab may freeze.

Expected behavior

Selection should take much less time

@arielkuzminski arielkuzminski added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 7, 2022
@arielkuzminski arielkuzminski changed the title MultiSelect: Very long selection time MultiSelect: Very long selection time due to Chips Dec 7, 2022
@arielkuzminski
Copy link
Author

arielkuzminski commented Dec 7, 2022

UPDATE:
https://codesandbox.io/s/primevue-multiselect-long-selection-time-forked-jf6tvc?file=/src/MultiSelectDemo.vue
I've found temporary solution but there's still something wrong with how base code works.
Solution:

  1. Use :maxSelectedLabels property even though we are using Chips
  2. Add code that is going to restrict display chips (yes, even though we already used maxSelectedLabels):
      <template #value="slotProps">
        <template v-if="slotProps.value && slotProps.value.length > MAX_CHIPS_DISPLAYED">
          {{ slotProps.value.length }} items selected
        </template>
      </template>

MAX_CHIPS_DISPLAYED is just a ref of type Number you want to restrict rendering

Funny (or sad) thing is that this solution is not working if you skip any of above steps. Those two steps have to work together.

@mertsincan mertsincan self-assigned this Dec 7, 2022
@mertsincan mertsincan added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 7, 2022
@mertsincan mertsincan added this to the 3.21.0 milestone Dec 7, 2022
@mertsincan
Copy link
Member

Hi @arielkuzminski,

I made some changes related to maxSelectedLabels and chips mode. For your case, you can use :maxSelectedLabels options.

Best Regards,

@arielkuzminski
Copy link
Author

Hi @arielkuzminski,

I made some changes related to maxSelectedLabels and chips mode. For your case, you can use :maxSelectedLabels options.

Best Regards,

Thanks for the contribution.

Good day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

2 participants