geido commented on code in PR #33271:
URL: https://github.com/apache/superset/pull/33271#discussion_r2071821615


##########
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx:
##########
@@ -288,58 +320,78 @@ export default function PluginFilterSelect(props: 
PluginFilterSelectProps) {
   );
 
   useEffect(() => {
-    if (defaultToFirstItem && filterState.value === undefined) {
-      // initialize to first value if set to default to first item
+    // Skip if only orientation changed
+    if (hasOnlyOrientationChanged.current) {
+      return;
+    }
+
+    // Case 1: Handle disabled state first
+    if (isDisabled) {
+      updateDataMask(null);
+      return;
+    }
+
+    // Case 2: Handle empty filter enabled case
+    if (enableEmptyFilter) {
+      if (defaultToFirstItem) {
+        // Set to first item if defaultToFirstItem is true
+        const firstItem: SelectValue = data[0]
+          ? (groupby.map(col => data[0][col]) as string[])
+          : null;
+        if (firstItem?.[0] !== undefined) {
+          updateDataMask(firstItem);
+        }
+      } else if (formData?.defaultValue) {
+        // Set to defaultValue if available
+        updateDataMask(formData.defaultValue);
+      }
+      return;
+    }

Review Comment:
   @amaannawab923 I am curious how these logics came into existence. It seems 
they are pretty much a duplicate of what's after? Should we reconsider if this 
is actually needed or DRY it up if it really is?



-- 
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