Skip to content

Commit

Permalink
fix: catch null value in onSelect (#2169)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahwaldner authored Jan 21, 2025
1 parent 57d7a63 commit 8dafc15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-nails-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@frontify/fondue-components": patch
---

fix: catch null value in the `onSelect` callback for the Select component
4 changes: 2 additions & 2 deletions packages/components/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type SelectComponentProps = {
/**
* Callback function that is called when an item is selected.
*/
onSelect?: (selectedValue: string) => void;
onSelect?: (selectedValue?: string) => void;
/**
* The active value in the select component. This is used to control the select externally.
*/
Expand Down Expand Up @@ -94,7 +94,7 @@ export const SelectInput = (
setHasInteractedSinceOpening(true);
},
onSelectedItemChange: ({ selectedItem }) => {
onSelect && onSelect(selectedItem.value);
onSelect && onSelect(selectedItem?.value);
},
itemToString: (item) => (item ? item.label : ''),
});
Expand Down

0 comments on commit 8dafc15

Please sign in to comment.