Explorar el Código

Fix enum default not pre-selected when `name` differs from `id`

The dropdown matches `selectedItem` by `id`, but `shouldSetDefault` was
storing `field.default` (the name) when matching by `name`, causing a
mismatch.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Mihaela Balutoiu hace 2 meses
padre
commit
81110da958
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      src/stores/WizardStore.ts

+ 3 - 1
src/stores/WizardStore.ts

@@ -127,7 +127,9 @@ class WizardStore {
 
         // Don't use the default if it can't be found in the enum list.
         if (isDefaultInEnum) {
-          return { should: true, value: field.default };
+          const matchedItem: any = isDefaultInEnum;
+          const value = matchedItem.id != null ? matchedItem.id : field.default;
+          return { should: true, value };
         }
       } else {
         return { should: true, value: field.default };