Skip to content
Merged
2 changes: 1 addition & 1 deletion components/pill-container/private/selected-listbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const getAvatar = (option) => {
};

const getIcon = (option) => {
const iconObject = option.icon;
const iconObject = option?.icon || null;
let icon = null;

if (iconObject) {
Expand Down
2 changes: 1 addition & 1 deletion components/pill/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class Pill extends React.Component {
};

renderIcon = () => {
const icon = this.props.icon || this.props.avatar;
const icon = this.props?.icon || this.props?.avatar;
Copy link
Contributor

@interactivellama interactivellama Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the situation that this.props becomes undefined within?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the undefined problem is comming beacuse of selected-listbox.jsx getIcon funtion as In some cases option only have icon or in other case only avatar, there i have applied const iconObject = option?.icon || null; and here const icon = this.props?.icon || this.props?.avatar; for the extra safety.

if (icon) {
return <span className="slds-pill__icon_container">{icon}</span>;
}
Expand Down