bito-code-review[bot] commented on code in PR #38479:
URL: https://github.com/apache/superset/pull/38479#discussion_r2897427452


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/utils.ts:
##########
@@ -64,12 +64,30 @@ export const checkIsApplyDisabled = (
   const dataSelectedValues = Object.values(dataMaskSelected);
   const dataAppliedValues = Object.values(dataMaskApplied);
 
-  const hasMissingRequiredFilter = filters.some(filter =>
-    checkIsMissingRequiredValue(
-      filter,
-      dataMaskSelected?.[filter?.id]?.filterState,
-    ),
-  );
+  // Check if any required filter is missing a value
+  // For filters that may have been auto-applied (e.g., requiredFirst filters),
+  // check both selected and applied states to avoid false positives during 
initialization
+  const hasMissingRequiredFilter = filters.some(filter => {
+    const selectedState = dataMaskSelected?.[filter?.id]?.filterState;
+    const appliedState = dataMaskApplied?.[filter?.id]?.filterState;
+
+    // If filter has value in selected state, it's not missing
+    if (
+      selectedState?.value !== null &&
+      selectedState?.value !== undefined
+    ) {
+      return false;
+    }
+
+    // If filter was auto-applied and has value in applied state, it's not 
missing
+    // This handles the case where auto-applied filters haven't synced to 
selected yet
+    if (appliedState?.value !== null && appliedState?.value !== undefined) {
+      return false;
+    }

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Logic Bug in Required Filter Check</b></div>
   <div id="fix">
   
   The applied state check should only apply when selected value is undefined 
(not set), not when it's null (user cleared). Otherwise, clearing a required 
filter allows apply if applied has a value, leading to invalid state.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       // If filter was auto-applied and has value in applied state, it's not 
missing
       // This handles the case where auto-applied filters haven't synced to 
selected yet
       if (selectedState?.value === undefined && appliedState?.value !== null 
&& appliedState?.value !== undefined) {
         return false;
       }
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #fb53db</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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