Compare commits

...
Author SHA1 Message Date
Evan Rusackas 89f9b4aea2 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.
2026-08-24 16:22:52 -07:00
2 changed files with 26 additions and 12 deletions
@@ -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 = {
@@ -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 () => {