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

   <!-- Bito Reply -->
   The flagged issue is correct. The `mapStateToProps` function for the 
`order_by_cols` control in 
`superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx` was 
previously missing a dependency on `all_columns`, which prevented the ordering 
choices from updating when the selected columns changed.
   
   The implemented fix in the PR addresses this by explicitly including 
`controls` in the `mapStateToProps` signature and using 
`controls?.all_columns?.value` to derive the available choices when the 
datasource is a `SemanticView`. This ensures that the ordering options are 
recomputed whenever the selected columns change.
   
   I have verified the changes in the provided diff, and they correctly 
implement the necessary dependency to resolve the stale reference issue.
   
   **superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx**
   ```
   mapStateToProps: ({ datasource, controls }) => {
                   if (datasource?.type === DatasourceType.SemanticView) {
                     const selectedColumns = [
                       ...new Set(
                         ensureIsArray(
                           controls?.all_columns?.value as
                             | QueryFormColumn[]
                             | undefined,
                         ).filter(isPhysicalColumn),
                       ),
                     ];
                     return {
                       choices: selectedColumns.flatMap(column => [
                         [
                           JSON.stringify([column, true]),
                           `${column} ${t('[asc]')}`,
                         ],
                         [
                           JSON.stringify([column, false]),
                           `${column} ${t('[desc]')}`,
                         ],
                       ]),
                     };
                   }
   ```


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