Browse Source

Merge pull request #1032 from richardshiue/fix-identical-selecion-options

fix: prevent select property from having identical options
Nathan.fooo 2 years ago
parent
commit
d6fa38a4b2

+ 5 - 1
frontend/app_flowy/lib/plugins/grid/application/field/type_option/multi_select_type_option.dart

@@ -51,7 +51,11 @@ class MultiSelectAction with ISelectOptionAction {
           (option) {
             typeOption.freeze();
             typeOption = typeOption.rebuild((typeOption) {
-              typeOption.options.insert(0, option);
+              final exists = typeOption.options
+                  .any((element) => element.name == option.name);
+              if (!exists) {
+                typeOption.options.insert(0, option);
+              }
             });
 
             return typeOption.options;

+ 5 - 1
frontend/app_flowy/lib/plugins/grid/application/field/type_option/single_select_type_option.dart

@@ -48,7 +48,11 @@ class SingleSelectAction with ISelectOptionAction {
           (option) {
             typeOption.freeze();
             typeOption = typeOption.rebuild((typeOption) {
-              typeOption.options.insert(0, option);
+              final exists = typeOption.options
+                  .any((element) => element.name == option.name);
+              if (!exists) {
+                typeOption.options.insert(0, option);
+              }
             });
 
             return typeOption.options;