From aaee530d1218e53b1bf16132e2b8b325a213e8f7 Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Thu, 27 Jun 2024 14:18:15 +0200 Subject: [PATCH] :bug: - fix: fix a bug that could cause a crash if the select options were removed --- src/components/form/select/select.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/form/select/select.tsx b/src/components/form/select/select.tsx index 6580afc6..affb2823 100644 --- a/src/components/form/select/select.tsx +++ b/src/components/form/select/select.tsx @@ -191,11 +191,14 @@ export const Select: React.FC = ({ }; 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 : "";