This is an automated email from the ASF dual-hosted git repository. rusackas pushed a commit to branch pr-34525 in repository https://gitbox.apache.org/repos/asf/superset.git
commit ee42ad55d23b8a76dc304abd1d07325afda0a6af Author: Evan Rusackas <e...@rusackas.com> AuthorDate: Sat Aug 2 23:01:00 2025 -0700 fix(table): hide conditional formatting color options without time comparison Fixes #34141 The "Green for increase, red for decrease" and "Red for increase, green for decrease" color scheme options were showing in table chart conditional formatting even when no time comparison was active. These options only work with time comparison data, so they should be hidden when time_compare is empty. Changes: - Modified both table chart control panels to dynamically show/hide color options based on time comparison - extraColorChoices now depends on hasTimeComparison check - Applied fix to both regular table chart and AG Grid table chart for consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <nore...@anthropic.com> --- .../src/controlPanel.tsx | 28 ++++++++++++++-------- .../plugin-chart-table/src/controlPanel.tsx | 28 ++++++++++++++-------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx index ec471429ac..f355a24136 100644 --- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/controlPanel.tsx @@ -673,16 +673,6 @@ const config: ControlPanelConfig = { type: 'ConditionalFormattingControl', renderTrigger: true, label: t('Custom conditional formatting'), - extraColorChoices: [ - { - value: ColorSchemeEnum.Green, - label: t('Green for increase, red for decrease'), - }, - { - value: ColorSchemeEnum.Red, - label: t('Red for increase, green for decrease'), - }, - ], description: t( 'Apply conditional color formatting to numeric columns', ), @@ -695,6 +685,23 @@ const config: ControlPanelConfig = { ) ? (explore?.datasource as Dataset)?.verbose_map : (explore?.datasource?.columns ?? {}); + + // Only show increase/decrease color options when time comparison is active + const hasTimeComparison = !isEmpty( + explore?.form_data?.time_compare, + ); + const extraColorChoices = hasTimeComparison + ? [ + { + value: ColorSchemeEnum.Green, + label: t('Green for increase, red for decrease'), + }, + { + value: ColorSchemeEnum.Red, + label: t('Red for increase, green for decrease'), + }, + ] + : []; const chartStatus = chart?.chartStatus; const { colnames, coltypes } = chart?.queriesResponse?.[0] ?? {}; @@ -725,6 +732,7 @@ const config: ControlPanelConfig = { removeIrrelevantConditions: chartStatus === 'success', columnOptions, verboseMap, + extraColorChoices, }; }, }, diff --git a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx index 9c998de5fb..a472763d82 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx @@ -730,16 +730,6 @@ const config: ControlPanelConfig = { type: 'ConditionalFormattingControl', renderTrigger: true, label: t('Custom conditional formatting'), - extraColorChoices: [ - { - value: ColorSchemeEnum.Green, - label: t('Green for increase, red for decrease'), - }, - { - value: ColorSchemeEnum.Red, - label: t('Red for increase, green for decrease'), - }, - ], description: t( 'Apply conditional color formatting to numeric columns', ), @@ -752,6 +742,23 @@ const config: ControlPanelConfig = { ) ? (explore?.datasource as Dataset)?.verbose_map : (explore?.datasource?.columns ?? {}); + + // Only show increase/decrease color options when time comparison is active + const hasTimeComparison = !isEmpty( + explore?.form_data?.time_compare, + ); + const extraColorChoices = hasTimeComparison + ? [ + { + value: ColorSchemeEnum.Green, + label: t('Green for increase, red for decrease'), + }, + { + value: ColorSchemeEnum.Red, + label: t('Red for increase, green for decrease'), + }, + ] + : []; const chartStatus = chart?.chartStatus; const { colnames, coltypes } = chart?.queriesResponse?.[0] ?? {}; @@ -782,6 +789,7 @@ const config: ControlPanelConfig = { removeIrrelevantConditions: chartStatus === 'success', columnOptions, verboseMap, + extraColorChoices, }; }, },