You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/08/24 23:23:19 UTC
(superset) 01/01: fix(plugin-chart-table): preserve comparison arrow when a column-specific formatter entry is missing
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch fix/table-arrow-fallback
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 89f9b4aea2a15b535385b4685233b8bb9a185af7
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Mon Aug 24 16:22:52 2026 -0700
fix(plugin-chart-table): preserve comparison arrow when a column-specific formatter entry is missing
The per-cell comparison arrow and arrow color are computed twice: once
from the row-level basicColorFormatters, then unconditionally reassigned
from basicColorColumnFormatters when that array is present. Unlike the
sibling backgroundColor assignment (which falls back to the prior value
via `|| backgroundColor`), the arrow and arrowColor reassignments had no
such fallback, so a row missing an entry in basicColorColumnFormatters
lost its arrow entirely and would have flipped its arrow color, even
though a valid value had already been computed from basicColorFormatters.
Falls back to the previously-computed value in both cases, same as
backgroundColor already does.
---
.../plugins/plugin-chart-table/src/TableChart.tsx | 24 +++++++++++++---------
.../plugin-chart-table/test/TableChart.test.tsx | 14 +++++++++++--
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
index 2045c3d8a0e..5cb501ac63d 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
@@ -1138,7 +1138,8 @@ export default function TableChart<D extends DataRecord = DataRecord>(
?.backgroundColor || backgroundColor;
arrow =
column.label === comparisonLabels[0]
- ? basicColorColumnFormatters[row.index]?.[column.key]?.mainArrow
+ ? (basicColorColumnFormatters[row.index]?.[column.key]
+ ?.mainArrow ?? arrow)
: '';
}
const rowSurfaceColor =
@@ -1209,15 +1210,18 @@ export default function TableChart<D extends DataRecord = DataRecord>(
basicColorColumnFormatters &&
basicColorColumnFormatters?.length > 0
) {
- arrowStyles = css`
- color: ${
- basicColorColumnFormatters[row.index]?.[column.key]
- ?.arrowColor === ColorSchemeEnum.Green
- ? theme.colorSuccess
- : theme.colorError
- };
- margin-right: ${theme.sizeUnit}px;
- `;
+ const columnArrowColor =
+ basicColorColumnFormatters[row.index]?.[column.key]?.arrowColor;
+ if (columnArrowColor) {
+ arrowStyles = css`
+ color: ${
+ columnArrowColor === ColorSchemeEnum.Green
+ ? theme.colorSuccess
+ : theme.colorError
+ };
+ margin-right: ${theme.sizeUnit}px;
+ `;
+ }
}
const cellProps = {
diff --git a/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx b/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
index 8a11044e2d8..8851987f95d 100644
--- a/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
@@ -2125,8 +2125,18 @@ describe('plugin-chart-table', () => {
'rgba(0, 150, 0, 0.2)',
);
- // the row missing a formatter entry still renders its raw value
- expect(screen.getAllByTitle('110').length).toBeGreaterThan(0);
+ // the row missing a formatter entry falls back to the row-level
+ // comparison arrow instead of losing it: before the fix, this row's
+ // arrow was silently cleared (and its color, computed the same way,
+ // would have flipped to the "decrease" color) whenever the
+ // column-specific lookup for this row was undefined.
+ const arrowCell = screen
+ .getAllByTitle('110')
+ .find(cell => cell.querySelector('span'));
+ expect(arrowCell).toHaveTextContent('↑110');
+ expect(getComputedStyle(arrowCell!).background).toContain(
+ 'rgba(0, 150, 0, 0.2)',
+ );
});
test('preserves client-side search text across temporal table rerenders', async () => {