fix(grid): prevent collapsible column group header from being inflated by minColumnWidth (#17042)#17048
Open
ivanvpetrov wants to merge 3 commits intomasterfrom
Open
Conversation
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
Agent added by mistake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TEST Bug fix PR entirely undertaken by bug-fixer custom agent (PR #17047 )
Closes #17042
Problem
After PR #16636,
IgxGridheaders and cells become misaligned when acollapsiblecolumn group is used and child columns have explicit widths smaller thanMINIMUM_COLUMN_WIDTH(136px).Steps to reproduce:
Scroll horizontally — the Info group header is 36px wider than the ID cell beneath it.
Root Cause
IgxColumnGroupComponentoverridesset width(val) {}as a no-op — width is computed dynamically from children — which meanswidthSetByUseris always false. Condition 3 added by PR #16636 ingetConstrainedSizePx()checked!this.widthSetByUseras part of its guard. Since this is always true for column groups, the constraint fired and inflated the group header tominColumnWidth(136px) even when children had smaller explicit widths.Fix
Changed condition 3 in
getConstrainedSizePx()incolumn.component.tsfrom:
to:
This ensures the
minColumnWidthfloor:✅ Still applies to leaf columns (
columnGroup = false)✅ Still applies to MRL column layouts (
columnLayout = true), which inheritscolumnGroup = trueviaIgxColumnGroupComponent)❌ Is skipped for regular column groups (
columnGroup = true),columnLayout = false), which derive their width purely from their children's computed widthsPotential Side Effects
None expected. The
columnLayoutguard was added specifically to preserve the unchanged behavior for MRL (IgxColumnLayoutComponent), which inheritscolumnGroup = trueand 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
widthvalues smaller than 136px (e.g.,width="100px") Setexpanded]="false"on the group so only one child is visibleScroll 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