primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.68k stars 1.01k forks source link

MultiSelect - breaking when options is empty array #2496

Closed ghost closed 2 years ago

ghost commented 2 years ago

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Current behavior I have a MultiSelect component being generated depending on a switch case. The options values are being generated programmatically in useEffect. However, the Multiselect is breaking for the generated options. It works fine if I provide a hardcoded value. The same generated values are working when given to a Dropdown component.

Error message: TypeError: Cannot read properties of null (reading 'length') at MultiSelect.isAllSelected

Expected behavior Expecting Multiselect to not break for programmatically generated options set.

Help...

melloware commented 2 years ago

Please provide a Code Sandbox reproducer so we can debug.

ghost commented 2 years ago

I'm unable to reproduce it in the code sandbox... any heads up on how I can debug this on my side..

Error message: Uncaught TypeError: Cannot read properties of null (reading 'length') at MultiSelect.isAllSelected (multiselect.esm.js:1480)

melloware commented 2 years ago

OK two things.

  1. Since you can't reproduce with Code Sandbox please close this ticket.

  2. What I normally do is start stripping one thing out at a time until I narrow down the problem with my code on what is causing the issue.

ghost commented 2 years ago

Closing because I'm unable to reproduce the issue in sandbox.

ghost commented 2 years ago

Reopening this issue. Able to reproduce the issue in sandbox : https://codesandbox.io/s/primereact-test-forked-0rbtt?file=/src/index.js

Choosing the first option will show the error and choosing the second option will show how it should look like but with multiselect instead of dropdown.

Similar issue was seen in PrimeNG, I believe : https://github.com/primefaces/primeng/issues/7941

melloware commented 2 years ago

Thanks for the reproducer. Let me take a look!