LuisSanchez commented on code in PR #37260:
URL: https://github.com/apache/superset/pull/37260#discussion_r2736732377


##########
superset-frontend/src/dashboard/components/nativeFilters/selectors.ts:
##########
@@ -281,8 +285,19 @@ const getStatus = ({
   }
   if (column && rejectedColumns?.has(column))
     return IndicatorStatus.Incompatible;
-  if (column && appliedColumns?.has(column) && hasValue) {
-    return APPLIED_STATUS;
+  // If filter has a value and column is not rejected, show as applied
+  // This works even when chart hasn't loaded yet (appliedColumns is empty)
+  // The dataMask state is the source of truth for filter application
+  if (column && hasValue && !rejectedColumns?.has(column)) {
+    // If chart has loaded and confirmed this column was applied, use that
+    if (appliedColumns?.has(column)) {
+      return APPLIED_STATUS;
+    }
+    // If chart hasn't loaded yet but we have a value, assume it's applied
+    // This allows showing filter indicators before query response is available
+    if (!appliedColumns || appliedColumns.size === 0) {

Review Comment:
   I was trying to add a refresh‑state icon to help out with this, and after 
refreshing the page I found that the `world_map` chart did not have 
`appliedColumns` set (the debug code at the end shows how I discovered this).
   
   So I took a different approach by setting the applied columns with a 
fallback instead.
   Please check `getAppliedColumnsWithFallback` on 
[superset-frontend/src/dashboard/components/nativeFilters/selectors.ts](https://github.com/apache/superset/pull/37260/files/bb10ceec045a6f33186c15bc026fb5fc3c746c4e#diff-b99fa1c34f77b95ef03afdaa8b9c7f6ef2a6841f8bfeedc65c6d691c2bff5e5c)
   
   ### Debug code:
   When refreshing the page: `appliedColumns` is empty, but `column` and 
`hasValue`, are not. This conditional is made to work mainly when the user 
refreshes the page.
   
   ``` javascript
   if (column && hasValue) {
     if (chart.form_data.viz_type === 'world_map') {
       console.log('----1ST CONDITION----', APPLIED_STATUS);
       console.log('CHART_TYPE', chart.form_data.viz_type);
       console.log('APPLIED_COLUMNS', appliedColumns);
       console.log('COLUMN', column);
       console.log('HAS VALUE', hasValue);
     }
     // If chart has loaded and confirmed this column was applied, use that
     if (appliedColumns?.has(column)) {
       if (chart.form_data.viz_type === 'world_map')
         console.log('----2ND CONDITION----', APPLIED_STATUS);
       return APPLIED_STATUS;
     }
     // If chart hasn't loaded yet but we have a value, assume it's applied
     // This allows showing filter indicators before query response is available
     if (!appliedColumns || appliedColumns.size === 0) {
       if (chart.form_data.viz_type === 'world_map')
         console.log('----3RD CONDITION----', APPLIED_STATUS);
       return APPLIED_STATUS;
     }
   }
   ```
   
   ### Browser logs immediately when applying filters.
   It works because it enters on 2nd conditional and `appliedColumns` is not 
empty because filters were just applied.
   
   <img width="542" height="408" alt="image" 
src="https://github.com/user-attachments/assets/a6b8ada2-d1a9-4704-af01-9e39e4eb4ce0";
 />
   
   ### If the page is refreshed (current bug):
   `appliedColumns` are now empty after the refresh.
   
   <img width="545" height="545" alt="image" 
src="https://github.com/user-attachments/assets/0b03489c-6d3f-4187-9a50-9b8ec8c5a7c7";
 />



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