salesforce / design-system-react

Salesforce Lightning Design System for React
https://react.lightningdesignsystem.com/
BSD 3-Clause "New" or "Revised" License
909 stars 411 forks source link

The Pills Container component tries to access a property of undefined (runtime major crash) #3138

Open VladimirParmonD opened 5 months ago

VladimirParmonD commented 5 months ago

Error summary: the Pills Component causes a major crash / runtime error

Where the error occurs: design-system-react\components\pill-container\private\selected-listbox.jsx at line 149, function getIcon

Error description: The function getIcon (pic 1) seems to handle the icon display for the currently selected option. Option === current selection, which legitimately can be undefined according to the component props (pic 2). The code tries to access the property option.icon and this results in an error "Cannot access property icon of undefined"

Proposed solution: since both selection and icon are optional props (pic 2), either change the props typings OR use optional chaining (?.) operator in the code. From the looks of it, the latter is preferable since the code handles the possible undefined everywhere except this one place. Seems like just a simple oversight but causes a big trouble in the app image image

welcome[bot] commented 5 months ago

Thanks for opening your first issue! :wave: If you have found this library helpful, please star it. A maintainer will try to respond within 7 days. If you haven’t heard anything by then, please bump this thread.

PushpakB3096 commented 5 months ago

I can work on this if no one has picked it yet.