Skip to content

feat: Table Column Groups Table#4482

Open
NathanZlion wants to merge 50 commits into
mainfrom
dev-v3-natidere-table-group
Open

feat: Table Column Groups Table#4482
NathanZlion wants to merge 50 commits into
mainfrom
dev-v3-natidere-table-group

Conversation

@NathanZlion
Copy link
Copy Markdown
Member

@NathanZlion NathanZlion commented Apr 30, 2026

Description

Add Table Column Grouping Feature support for Table Component.

Related links, issue AWSUI-9594, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@NathanZlion NathanZlion changed the title chore: Add test page and interface change for table feat: Table Column Groups Table May 3, 2026
@NathanZlion NathanZlion force-pushed the dev-v3-natidere-table-group branch from 40c20ee to 84451af Compare May 4, 2026 13:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 95.28487% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.39%. Comparing base (f493264) to head (b0a1437).
⚠️ Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
src/table/thead.tsx 91.79% 11 Missing ⚠️
src/table/use-column-widths.tsx 89.65% 6 Missing ⚠️
src/table/table-role/utils.ts 94.11% 3 Missing ⚠️
src/table/column-groups/utils.ts 99.20% 1 Missing ⚠️
src/table/header-cell/group-header-cell.tsx 95.83% 1 Missing ⚠️
src/table/sticky-scrolling.ts 0.00% 1 Missing ⚠️
src/table/table-role/grid-navigation.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4482      +/-   ##
==========================================
- Coverage   97.41%   97.39%   -0.03%     
==========================================
  Files         933      942       +9     
  Lines       29595    30094     +499     
  Branches    10757    10969     +212     
==========================================
+ Hits        28831    29309     +478     
- Misses        716      778      +62     
+ Partials       48        7      -41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@NathanZlion NathanZlion force-pushed the dev-v3-natidere-table-group branch from 84451af to e9f4fd0 Compare May 4, 2026 15:59
@NathanZlion NathanZlion force-pushed the dev-v3-natidere-table-group branch from d6a98cb to 5cec8c8 Compare May 5, 2026 14:22
@NathanZlion NathanZlion marked this pull request as ready for review May 6, 2026 08:36
@NathanZlion NathanZlion requested a review from a team as a code owner May 6, 2026 08:36
@NathanZlion NathanZlion requested review from georgylobko and removed request for a team and georgylobko May 6, 2026 08:36
@NathanZlion NathanZlion marked this pull request as draft May 6, 2026 11:40
@NathanZlion NathanZlion force-pushed the dev-v3-natidere-table-group branch from 8da3b07 to 227f21b Compare May 8, 2026 00:37
…er, remove inline colgroup from sticky heder
Comment thread src/table/utils.ts Outdated
}: {
columnDisplay?: ReadonlyArray<TableProps.ColumnDisplayProperties>;
visibleColumns?: ReadonlyArray<string>;
visibleColumns?: ReadonlyArray<string | number>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this string | number now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const getColumnKey = <T>(column: TableProps.ColumnDefinition<T>, index: number) => {
return column.id || index;
};

The getColumnKey returns column.id || index when a column definition doesn't have an explicit id, it falls back to the numeric array index.

The column groups code path (useColumnGroups > calculateHierarchyTree > getVisibleColumnDefinitions), which previously only accepted string.

export function useColumnGroups<T>(
columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<T>>,
groupDefinitions?: ReadonlyArray<TableProps.GroupDefinition>,
visibleColumns?: Set<string>,
columnDisplay?: ReadonlyArray<TableProps.ColumnDisplayProperties>
) {
return useMemo(() => {
const visibleIds = visibleColumns
? Array.from(visibleColumns)
: columnDefinitions.map((col, idx) => getColumnKey(col, idx));
const layout = calculateHierarchyTree(columnDefinitions, visibleIds, groupDefinitions ?? [], columnDisplay);

If it's okay I could just cast the type only in the useColumnGroups, and we din't have to do all the | number in all the props.

    const visibleIds = visibleColumns
      ? Array.from(visibleColumns)
      : columnDefinitions.map((col, idx) => getColumnKey(col, idx).toString());

I'm fine with both

Comment thread src/table/use-column-widths.tsx Outdated
setColumnWidths(columnWidths => updateWidths(visibleColumns, columnWidths ?? new Map(), newWidth, columnId));
}

/* istanbul ignore next: covered by integration tests, requires real DOM measurements */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some unit tests for column widths here: src/table/tests/columns-width.test.tsx

Can these tests be extended to support the groups use cases?

Comment thread src/table/thead.tsx Outdated
const { getColumnStyles, columnWidths, updateColumn, setCell } = useColumnWidths();
const { getColumnStyles, columnWidths, updateColumn, updateGroup, setCell } = useColumnWidths();

const handleSplitGroupResize = (leafIds: string[], newWidth: number) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are "leaf ids" here - is that columns ids or can it be groups, too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a column only, I will rename the leaf to colmn to make it less confusing

styles.label,
styles.root,
verticalAlign === 'top' && !spansRows && styles['label-top'],
spansRows && styles['label-bottom']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this create an inconsistent look? I think the reason we have 'lavel-top' is to ensure the selection element is at the top of the cell when the column headers are multiline (with wrap-lines: true). Now, with col groups + wrap-lines it will look different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants