Skip to content

Commit

Permalink
LPD-39583 - Check if selectedItem exists before referencing it
Browse files Browse the repository at this point in the history
  • Loading branch information
kresimir-coko committed Oct 23, 2024
1 parent 20c16b7 commit 7703ec1
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const TriggerButton = React.forwardRef(
) => {
const ariaLabelButton = sub(
Liferay.Language.get('select-a-language.-current-language-x'),
selectedItem.displayName
selectedItem?.displayName
);

return displayType === DISPLAY_TYPE.HORIZONTAL ? (
Expand All @@ -73,10 +73,10 @@ const TriggerButton = React.forwardRef(
size="sm"
>
<span className="inline-item-before">
<ClayIcon symbol={selectedItem.symbol} />
<ClayIcon symbol={selectedItem?.symbol} />
</span>

<span aria-hidden="true">{selectedItem.label}</span>
<span aria-hidden="true">{selectedItem?.label}</span>
</ClayButton>
) : (
<ClayButton
Expand All @@ -90,11 +90,11 @@ const TriggerButton = React.forwardRef(
title={Liferay.Language.get('select-a-language')}
>
<span className="inline-item">
<ClayIcon symbol={selectedItem.symbol} />
<ClayIcon symbol={selectedItem?.symbol} />
</span>

<span aria-hidden="true" className="btn-section">
{selectedItem.label}
{selectedItem?.label}
</span>
</ClayButton>
);
Expand Down

0 comments on commit 7703ec1

Please sign in to comment.