ahirner opened a new issue, #37413:
URL: https://github.com/apache/superset/issues/37413
### Bug description
## Description
(AI generated)
When using the Table Chart with Time Shift (Comparison) enabled, disabling a
column via the Customize > Column configuration menu causes the table headers
to become misaligned.
The "Grouping Headers" (the headers spanning "Main", "#", "△", "%")
calculate their colSpan and positions based on the full list of columns before
the visibility check is applied. However, the table body renders only the
visible columns. This results in headers shifting to the right or spanning too
many columns, breaking the visual layout.
## Reproduction Steps
1. Create a Table Chart in Superset.
2. In the Data tab, enable Time Shift (e.g., "1 year ago").
3. Verify the chart renders with comparison columns (Main, #, △, %).
4. Go to the Customize tab.
5. Under Column configuration, expand a column and uncheck Show visible.
6. Result: The table body hides the column correctly, but the grouped header
above it (e.g., "Main") retains the original width/position, causing
misalignment.
Technical Analysis
File: superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
The issue stems from a discrepancy in the data source used for headers
versus the body:
1. Headers (groupHeaderColumns): Calculates groups using
filteredColumnsMeta. This list excludes columns removed via the "Data" tab but
includes columns hidden via the "Customize" tab (config.visible: false).
2. Body (columns): Renders using visibleColumnsMeta. This list excludes
columns hidden via the "Customize" tab.
Because filteredColumnsMeta has more items than visibleColumnsMeta, the
indices calculated for the grouped headers do not match the indices of the
rendered cells.
Snippet (Current State)
// Line ~705
const groupHeaderColumns = useMemo(
() => getHeaderColumns(filteredColumnsMeta, isUsingTimeComparison), //
Uses unfiltered list
[filteredColumnsMeta, getHeaderColumns, isUsingTimeComparison],
);
// ...
// Line ~1182 (Defined too late!)
const visibleColumnsMeta = useMemo(
() => filteredColumnsMeta.filter(col => col.config?.visible !== false),
[filteredColumnsMeta, getHeaderColumns],
);
## Proposed Fix
We need to align the header logic to use the same "Visible Columns" list as
the body.
1. Move visibleColumnsMeta definition:
Move the useMemo for visibleColumnsMeta up in the component (around line
700), before groupHeaderColumns is defined.
2. Update Header Calculation:
Change groupHeaderColumns to calculate based on visibleColumnsMeta.
const groupHeaderColumns = useMemo(
() => getHeaderColumns(visibleColumnsMeta, isUsingTimeComparison),
[visibleColumnsMeta, getHeaderColumns, isUsingTimeComparison],
);
3. Update Header Rendering:
Inside renderGroupingHeaders, ensure we are accessing column metadata
from visibleColumnsMeta to match the indices.
// Inside renderGroupingHeaders loop
const firstColumnInGroup = visibleColumnsMeta[startPosition];
Implementation Plan
1. Edit superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx.
2. Locate visibleColumnsMeta at the bottom and move it up to line ~700.
3. Refactor groupHeaderColumns to use visibleColumnsMeta.
4. Refactor renderGroupingHeaders to use visibleColumnsMeta.
### Screenshots/recordings
Toggling off two`%` columns make the other columns move into the top level
columns:
<img width="891" height="60" alt="Image"
src="https://github.com/user-attachments/assets/df1d01fc-0ef2-423d-96b6-162c0225c1b4"
/>
With all columns visible, headers (and value) columns align more or less OK:
<img width="892" height="72" alt="Image"
src="https://github.com/user-attachments/assets/dd6521ba-dcde-44ed-bc38-a3c5204445b5"
/>
### Superset version
6.0.0
### Python version
Not applicable
### Node version
I don't know
### Browser
Safari
### Additional context
Custom build but with frontend as published
https://github.com/ahirner/nix-trickle/pkgs/container/superset-granian
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [ ] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
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]