FrancescoCastaldi commented on code in PR #44894:
URL: https://github.com/apache/superset/pull/44894#discussion_r4243546582


##########
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx:
##########
@@ -380,7 +381,19 @@ const AsyncSelect = forwardRef(
           // merges with existing and creates unique options
           setSelectOptions(prevOptions => {
             mergedData = prevOptions
-              .filter(previousOption => !dataValues.has(previousOption.value))
+              .filter(previousOption => {
+                if (dataValues.has(previousOption.value)) {
+                  return false;
+                }
+                if (
+                  previousOption.isNewOption &&
+                  (hasOption(previousOption.label as V, data, true) ||
+                    hasOption(previousOption.value as V, data, true))
+                ) {

Review Comment:
   Resolved in commit `e7c9b0e0de`: updated `getOption` in `Select/utils.tsx` 
to recursively inspect child `options` when encountering option groups 
(`isObject(x) && Array.isArray(x.options)`), ensuring that matching child 
options within grouped structures are identified and optimistic duplicates are 
dropped properly.



##########
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx:
##########
@@ -380,7 +381,19 @@ const AsyncSelect = forwardRef(
           // merges with existing and creates unique options
           setSelectOptions(prevOptions => {
             mergedData = prevOptions
-              .filter(previousOption => !dataValues.has(previousOption.value))
+              .filter(previousOption => {
+                if (dataValues.has(previousOption.value)) {
+                  return false;
+                }
+                if (
+                  previousOption.isNewOption &&
+                  (hasOption(previousOption.label as V, data, true) ||
+                    hasOption(previousOption.value as V, data, true))
+                ) {
+                  return false;
+                }

Review Comment:
   Resolved in commit `7019744718`: extracted the shared predicate 
`isRedundantNewOption` in `AsyncSelect.tsx` and unified the duplicate check 
across `mergeData` and the initial page search response filter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to