[Bug]: Crash in MultiSelect with undefined selectedItems #16052
Labels
component: multi-select
role: dev 🤖
severity: 4
Unrelated to a user task, has a workaround or does not need a workaround
type: bug 🐛
Package
@carbon/react
Browser
Chrome
Package version
v1.53.0
React version
v18.2.0
Description
This is admittedly user error, but it seems like it would be a good idea to protect against it.
If
selectedItems
has an array withundefined
in it, this PR will try to readtext
from undefined and crash with the stack below:I hit it b/c we had some bad test code, but figured it would be a good idea to just add some optional chaining in that MultiSelect code so it doesn't crash.
Reproduction/example
https://stackblitz.com/edit/github-caiwsw?file=src%2FApp.jsx
Steps to reproduce
Create a multiselect
in
selectedItems
, have an item that is undefined or null.Suggested Severity
Severity 4 = Unrelated to a user task, has a workaround or does not need a workaround.
Application/PAL
IBM Cloud Satellite
Code of Conduct
The text was updated successfully, but these errors were encountered: