fix(striker-ui): handle case where display value isn't filled in select with label

main
Tsu-ba-me 9 months ago
parent 0e762c3a44
commit 373f985911
  1. 17
      striker-ui/components/SelectWithLabel.tsx

@ -103,10 +103,19 @@ const SelectWithLabel = <
const menuItemElements = useMemo( const menuItemElements = useMemo(
() => () =>
selectItems.map((item) => { selectItems.map((item) => {
const { value, displayValue }: SelectItem<Value, Display> = /**
typeof item === 'object' * Cases:
? item * 1. item is string
: { displayValue: item as Display, value: item as Value }; * 2. item is SelectItem with only value
* 3. item is SelectItem with both value, and displayValue
*/
if (typeof item === 'string') return createMenuItem(item, item);
const {
value,
displayValue = String(value),
}: SelectItem<Value, Display> = item;
return createMenuItem(value, displayValue); return createMenuItem(value, displayValue);
}), }),

Loading…
Cancel
Save