mikebridge commented on code in PR #44806:
URL: https://github.com/apache/superset/pull/44806#discussion_r4190635534


##########
superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx:
##########
@@ -352,11 +353,36 @@ const config: ControlPanelConfig = {
               description: t('Order results by selected columns'),
               multi: true,
               default: [],
-              mapStateToProps: ({ datasource }) => ({
-                choices: datasource?.hasOwnProperty('order_by_choices')
-                  ? (datasource as Dataset)?.order_by_choices
-                  : datasource?.columns || [],
-              }),
+              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]')}`,
+                      ],
+                    ]),
+                  };

Review Comment:
   Thanks, this is a real stale-choice issue. Addressed in 
39e4af18e7a0a006923c251e4259ad5d4d07655b: `all_columns` declares `rerender: 
['order_by_cols']`. Explore reads the changed control's `rerender` list, so the 
dependency runs in that direction rather than on the Ordering control. A 
reducer regression verifies that new choices appear, removed sorts are pruned 
from both the control and the saved form data, and valid sorts remain.



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