Skip to content

Commit

Permalink
🐛 - fix: fix a bug that could cause a crash if the select options wer…
Browse files Browse the repository at this point in the history
…e removed
  • Loading branch information
svenvandescheur committed Jun 28, 2024
1 parent 51478cd commit aaee530
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/form/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,14 @@ export const Select: React.FC<SelectProps> = ({
};

const selectedOptionLabel =
selectedIndex !== null ? options[selectedIndex].label : undefined;
selectedIndex !== null ? options[selectedIndex]?.label : undefined;

const selectedOptionValue =
selectedIndex !== null
? Object.prototype.hasOwnProperty.call(options[selectedIndex], "value")
? Object.prototype.hasOwnProperty.call(
options[selectedIndex] || {},
"value",
)
? options[selectedIndex].value
: selectedOptionLabel
: "";
Expand Down

0 comments on commit aaee530

Please sign in to comment.