From 405fcfc5b1491b9fa69df8d7c77cf5e22f2d55f8 Mon Sep 17 00:00:00 2001 From: amaannawab923 Date: Wed, 21 May 2025 18:30:25 +0530 Subject: [PATCH] fix(table): table sort by fix (#33540) Co-authored-by: Amaan Nawab Co-authored-by: Geido <60598000+geido@users.noreply.github.com> --- .../plugin-chart-table/src/controlPanel.tsx | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx index ef3a8e700c2..ee3c43a0ec2 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx @@ -326,6 +326,26 @@ const config: ControlPanelConfig = { }, }, ], + [ + { + name: 'order_desc', + config: { + type: 'CheckboxControl', + label: t('Sort descending'), + default: true, + description: t( + 'If enabled, this control sorts the results/values descending, otherwise it sorts the results ascending.', + ), + visibility: ({ controls }: ControlPanelsContainerProps) => { + const hasSortMetric = Boolean( + controls?.timeseries_limit_metric?.value, + ); + return hasSortMetric && isAggMode({ controls }); + }, + resetOnHide: false, + }, + }, + ], [ { name: 'server_pagination', @@ -362,21 +382,6 @@ const config: ControlPanelConfig = { }, }, ], - [ - { - name: 'order_desc', - config: { - type: 'CheckboxControl', - label: t('Sort descending'), - default: true, - description: t( - 'If enabled, this control sorts the results/values descending, otherwise it sorts the results ascending.', - ), - visibility: isAggMode, - resetOnHide: false, - }, - }, - ], [ { name: 'show_totals',