bito-code-review[bot] commented on PR #40815:
URL: https://github.com/apache/superset/pull/40815#issuecomment-4635942320

   <!-- Bito Reply -->
   The flagged issue is correct. The `useMatrixifyAllowedValues` hook relies on 
`useState` initialized only on mount, which causes it to retain stale `success` 
state when the `formData` (and thus the `columnsKey`) changes. This creates a 
race condition where the grid can be rendered using stale, unfiltered data 
before the new request completes.
   
   To resolve this, you should track the `columnsKey` in state or use a 
`useEffect` that resets the status to `loading` whenever the `columnsKey` 
changes. Here is a concise implementation pattern:
   
   ```typescript
   // Inside useMatrixifyAllowedValues.ts
   const [state, setState] = useState({ status: 'loading', allowedByColumn: {} 
});
   const columnsKey = getDimensionColumns(formData).join(',');
   
   useEffect(() => {
     setState(prev => ({ ...prev, status: 'loading' }));
     // ... trigger fetch ...
   }, [columnsKey]);
   ```
   
   I have checked the available PR context, and there are no other actionable 
review comments to address at this time. Would you like me to perform any 
further analysis on this PR?
   
   
**superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/useMatrixifyAllowedValues.ts**
   ```
   const [state, setState] = useState({ status: 'loading', allowedByColumn: {} 
});
   const columnsKey = getDimensionColumns(formData).join(',');
   
   useEffect(() => {
     setState(prev => ({ ...prev, status: 'loading' }));
     // ... trigger fetch ...
   }, [columnsKey]);
   ```


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