Jelajahi Sumber

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 2 bulan lalu
induk
melakukan
81110da958
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  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 };