Skip to content

fix(grid): prevent collapsible column group header from being inflated by minColumnWidth (#17042)#17048

Open
ivanvpetrov wants to merge 3 commits intomasterfrom
copilot/fix-collapsible-column-group-width-misalignment
Open

fix(grid): prevent collapsible column group header from being inflated by minColumnWidth (#17042)#17048
ivanvpetrov wants to merge 3 commits intomasterfrom
copilot/fix-collapsible-column-group-width-misalignment

Conversation

@ivanvpetrov
Copy link
Contributor

TEST Bug fix PR entirely undertaken by bug-fixer custom agent (PR #17047 )

Closes #17042

Problem

After PR #16636, IgxGrid headers and cells become misaligned when a collapsible column group is used and child columns have explicit widths smaller than MINIMUM_COLUMN_WIDTH (136px).

Steps to reproduce:

<igx-grid [data]="data">
  <igx-column-group header="Info" [collapsible]="true" [expanded]="false">
    <igx-column field="ID" width="100px" [visibleWhenCollapsed]="true"></igx-column>
    <igx-column field="Name" width="100px" [visibleWhenCollapsed]="false"></igx-column>
  </igx-column-group>
  <igx-column field="Phone"></igx-column>
</igx-grid>

Scroll horizontally — the Info group header is 36px wider than the ID cell beneath it.

Root Cause

IgxColumnGroupComponent overrides set width(val) {} as a no-op — width is computed dynamically from children — which means widthSetByUser is always false. Condition 3 added by PR #16636 in getConstrainedSizePx() checked !this.widthSetByUser as part of its guard. Since this is always true for column groups, the constraint fired and inflated the group header to minColumnWidth (136px) even when children had smaller explicit widths.

Fix

Changed condition 3 in getConstrainedSizePx() in column.component.ts
from:

// Before
} else if (!this.columnGroup && !this.minWidth && (!this.widthSetByUser || this.width === 'fit-content') && ...)

to:

// After
} else if ((this.columnLayout || !this.columnGroup) && !this.minWidth && (!this.widthSetByUser || this.width === 'fit-content') && ...)

This ensures the minColumnWidth floor:

✅ Still applies to leaf columns (columnGroup = false)
✅ Still applies to MRL column layouts (columnLayout = true), which inherits columnGroup = true via IgxColumnGroupComponent)
❌ Is skipped for regular column groups (columnGroup = true), columnLayout = false), which derive their width purely from their children's computed widths

Potential Side Effects

None expected. The columnLayout guard was added specifically to preserve the unchanged behavior for MRL (IgxColumnLayoutComponent), which inherits columnGroup = true and would otherwise have been inadvertently excluded from the constraint. All 1908 grid tests pass.

How to Test

Create a grid with a collapsible column group where child columns have explicit width values smaller than 136px (e.g., width="100px") Set expanded]="false" on the group so only one child is visible
Scroll right — the group header should now align with the cell beneath it
Run npm run test:lib:grid — all tests should pass with no regressions

Column groups (IgxColumnGroupComponent) compute their width as the sum of
their visible children's calcWidth. However, the minColumnWidth constraint
added in PR #16636 was incorrectly applying to non-layout column groups
because their widthSetByUser is always false (the set width() setter is a
no-op override).

When a visible collapsed child had an explicit width smaller than the grid's
minColumnWidth (136px), getConstrainedSizePx() inflated the group header
width to 136px while the cell stayed at the child's explicit width, causing
a visible header/cell misalignment when scrolling horizontally.

Fix: update condition 3 of getConstrainedSizePx() from '!this.columnGroup'
to '(this.columnLayout || !this.columnGroup)', so the minColumnWidth floor
applies to:
- leaf columns (columnGroup = false)
- MRL column layouts (columnLayout = true, columnGroup = true)

but is skipped for regular non-layout column groups (columnGroup = true,
columnLayout = false), which derive their width purely from children.

Closes #17042
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.

IgxGrid: headers & cells misalignment when there are column groups and columns have widths set

1 participant