codeant-ai-for-open-source[bot] commented on code in PR #35897:
URL: https://github.com/apache/superset/pull/35897#discussion_r2773326094
##########
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:
##########
@@ -935,18 +939,43 @@ export default function TableChart<D extends DataRecord =
DataRecord>(
formatter.getColorFromValue(valueToFormat);
if (!formatterResult) return;
- if (formatter.toTextColor) {
+ if (
+ formatter.objectFormatting === ObjectFormattingEnum.TEXT_COLOR
+ ) {
color = formatterResult.slice(0, -2);
+ } else if (
+ formatter.objectFormatting === ObjectFormattingEnum.CELL_BAR
+ ) {
+ if (showCellBars)
+ backgroundColorCellBar = formatterResult.slice(0, -2);
} else {
backgroundColor = formatterResult;
+ valueRangeFlag = false;
}
};
columnColorFormatters
- .filter(formatter => formatter.column === column.key)
- .forEach(formatter => applyFormatter(formatter, value));
+ .filter(formatter => {
+ if (formatter.columnFormatting) {
+ return formatter.columnFormatting === column.key;
+ }
+ return formatter.column === column.key;
+ })
+ .forEach(formatter => {
+ let valueToFormat;
+ if (formatter.columnFormatting) {
+ valueToFormat = row.original[formatter.column];
+ } else {
+ valueToFormat = value;
+ }
+ applyFormatter(formatter, valueToFormat);
+ });
columnColorFormatters
- .filter(formatter => formatter.toAllRow)
+ .filter(
+ formatter =>
+ formatter.columnFormatting ===
Review Comment:
**Suggestion:** The filter for entire-row conditional formatting incorrectly
checks `columnFormatting` against `ObjectFormattingEnum.ENTIRE_ROW` instead of
`objectFormatting`, so entire-row formatters are never applied and row-level
styling silently fails. [logic error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ⚠️ Entire-row conditional formatting silently ignored.
- ❌ User-configured row-level styles not applied.
- ⚠️ Affects conditional formatting feature UX.
```
</details>
```suggestion
formatter.objectFormatting ===
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open TableChart's getColumnConfigs -> Cell in
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx. The
ENTIRE_ROW handling
begins at line 973 where columnColorFormatters are filtered for entire-row
formatters.
2. Configure a conditional formatting rule in the UI that targets the entire
row
(objectFormatting set to ObjectFormattingEnum.ENTIRE_ROW). The formatter
objects pushed by
getColorFormatters include an objectFormatting property (see
superset-ui-chart-controls
getColorFormatters utility).
3. Render a table with such an entire-row formatter. The current code
filters on
formatter.columnFormatting === ObjectFormattingEnum.ENTIRE_ROW
(TableChart.tsx:973) —
columnFormatting is a different field (it points at column-scoped configs)
so the
ENTIRE_ROW rule does not match and is never applied.
4. Observe that row-level conditional formatting (background/foreground for
the whole row)
is not applied despite a valid ENTIRE_ROW rule configured. This is a logic
bug (not a
hypothetical mismatch); replacing the check with formatter.objectFormatting
resolves the
issue and allows ENTIRE_ROW formatters to run.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
**Line:** 976:976
**Comment:**
*Logic Error: The filter for entire-row conditional formatting
incorrectly checks `columnFormatting` against `ObjectFormattingEnum.ENTIRE_ROW`
instead of `objectFormatting`, so entire-row formatters are never applied and
row-level styling silently fails.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
```
</details>
--
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]