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 - breaking when options is empty array #2496

Closed
ghost opened this issue Dec 6, 2021 · 6 comments · Fixed by #2500
Closed

MultiSelect - breaking when options is empty array #2496

ghost opened this issue Dec 6, 2021 · 6 comments · Fixed by #2500
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@ghost
Copy link

ghost commented Dec 6, 2021

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...

  • React version:
    17.0.2

  • PrimeReact version:
    6.5.1

@melloware
Copy link
Member

Please provide a Code Sandbox reproducer so we can debug.

@ghost
Copy link
Author

ghost commented Dec 6, 2021

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
Copy link
Member

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 ghost closed this as completed Dec 6, 2021
@ghost
Copy link
Author

ghost commented Dec 6, 2021

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

@ghost ghost reopened this Dec 6, 2021
@ghost
Copy link
Author

ghost commented Dec 6, 2021

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 : primefaces/primeng#7941

@melloware
Copy link
Member

Thanks for the reproducer. Let me take a look!

melloware added a commit to melloware/primereact that referenced this issue Dec 7, 2021
mertsincan added a commit that referenced this issue Dec 10, 2021
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label Dec 10, 2021
@mertsincan mertsincan modified the milestones: 8.0.0, 7.1.0 Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants