Procházet zdrojové kódy

Merge pull request #767 from smiclea/label-default

Support default value as item label in options
Daniel Vincze před 2 roky
rodič
revize
f284f5bc72
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. 4 1
      src/components/ui/FieldInput/FieldInput.tsx

+ 4 - 1
src/components/ui/FieldInput/FieldInput.tsx

@@ -313,7 +313,10 @@ class FieldInput extends React.Component<Props> {
     }
 
     const selectedItem = items.find(
-      i => !isEnumSeparator(i) && i.value === this.props.value
+      i =>
+        !isEnumSeparator(i) &&
+        // The default value might be set to an item's label instead of its value
+        (i.value === this.props.value || i.label === this.props.value)
     );
     const commonProps = {
       width: this.props.width,