Repository navigation
fix(grid): pin a column with a small minWidth through pinned - #18064
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The tests do not cover the new non-finite-width fallback for hidden columns; a regression case should verify minimum-width calculation and pinning/unpinning after the column is shown.
1 open issue
What changed in this PR
Fixes #18039 in shared grid column sizing so columns without an explicit width and with minWidth below 136px can be pinned and unpinned when space is exhausted, while preserving the smaller-width behavior introduced for #16057.
Changes:
- Recalculates eligible column widths, handles non-finite results, and stores the constrained pixel width.
- Adds regression tests for pinning and minimum-width sizing.
- Documents the fix in the changelog.
| File | Description |
|---|---|
projects/igniteui-angular/grids/grid/src/grid.pinning.spec.ts |
Tests pinning through the input and unpinning through the property. |
projects/igniteui-angular/grids/grid/src/column-resizing.spec.ts |
Verifies minimum widths when grid space is exhausted. |
projects/igniteui-angular/grids/core/src/columns/column.component.ts |
Corrects width calculation and adds a non-finite fallback. |
CHANGELOG.md |
Records the column-pinning fix. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The shared column-sizing changes affect Grid, Tree Grid, and Hierarchical Grid with multi-pass cache state, so approval should wait for runtime and browser-level regression coverage across grouped, percentage, hidden, pinned, and resize/reflow scenarios.
Review effort: Lite
|
After further testing I found the following gap - which is not blocking for the PR:
|
mddragnev
left a comment
There was a problem hiding this comment.
The division by zero is still reachable as @Marina-L-Stoyanova already said. The isFinite fallback only protects cacheCalcWidth.
I'd suggest guarding the division where it happens, in getPossibleColmnWidth, and dropping the fallback in cache.
Also, please do not commit the sample that you`ve used to test the issue.
PS. I agree that the second point in Marina's comment belong in a separate issue.
|
Thanks @Marina-L-Stoyanova and @mddragnev, I applied the suggestion:
While testing i found that the division by zero is not limited to columns with a small
The |
There was a problem hiding this comment.
🔵 Needs a closer look
The patch changes shared width allocation and hidden-column pinning across multiple grid modes, requiring targeted browser regression coverage for multi-row layouts, resizing, and custom minimum-width cases.
No open issues 🎉
1 resolved since last review
Review effort: Lite
I asked for the demo update to be committed. |
mddragnev
left a comment
There was a problem hiding this comment.
There is a new regression after the last changes:
- A column with only a
maxWidthshrinks to 136px. In a 1000px grid with a 200px column and a column withmaxWidth="300px", the second column is 136px instead of 300px. It stays at 136px at any grid width, because the third branch ofgetConstrainedSizePx()returnsminColumnWidthwithout clearingwidthConstrained. - A column held at a
minWidthof 136px or more stops growing. In a 400px grid with a 200px column and a column withminWidth="300px", widening the grid to 1200px leaves the second column at 300px. On master it grows to 1000px.
Here is a patch that you can git apply for a sample that shows both issues
pr18064-column-sizing-qa.patch
|
@onlyexeption Could you please update the 22.3 and 21.2 branches as well? |

Closes #18039
Description
Setting
pinnednow pins and unpins a column that has nowidthand aminWidthbelow 136px, even when the grid has no space left for that column. Settingpinnedon a hidden column that has nowidthalso pins it when it is shown.Changes in
getPossibleColumnWidth()(grid-base.directive.ts):widthor is held at itsminWidthormaxWidth, the held columns are sized again with the space the other columns leave, so they follow the grid width.width, it returns the minimum column width (136px) instead of dividing by 0, so a hidden column without awidthgets a pixel width. Multi-row layouts are not changed.Changes in
cacheCalcWidth()(column.component.ts), for a column that has nowidthand aminWidthbelow 136px:widthConstrained, so the column is always sized with the columns that have nowidth.defaultWidthis set to the calculated width, sowidthreturns a pixel value such as50px.Motivation / Context
After the first sizing pass, a column held at its
minWidthormaxWidthis markedwidthConstrained, so the next pass no longer counts it with the columns that have nowidth. When it is the only such column,getPossibleColumnWidth()divides by 0, andwidthreturns-InfinitypxorInfinitypx. Thepinnedsetter callspin()orunpin()only whenparseInt(width)is a number. Otherwise it only changes the flag, so the column stays where it was. A hidden column without awidthgets the same non-finite width when every visible column has awidthor is held at itsminWidthormaxWidth.The non-finite width also kept a column at its
maxWidthafter the grid got narrower, so the grid showed a horizontal scrollbar. The column now takes the space that is left, as it does when the grid starts at that width.The bug has existed since 20.1.0 (#16134). The fixes suggested in the issue break existing sizing behavior, such as #16057.
Needs backports to 22.3.x and 21.2.x.
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
Grids (Grid, Tree Grid, Hierarchical Grid): column sizing and pinning
How Has This Been Tested?
New tests (all 8 fail on master):
grid.pinning.spec.ts:pinnedinputpinnedproperty afterpin()minWidthbelow 136px through thepinnedinput when it is shownwidthwhen it is shown, when every visible column has awidthwidthis held at itsmaxWidthcolumn-resizing.spec.ts:minWidth(widthis50pxandcalcPixelWidthis 50)maxWidth="300px"is 300px wide in a 1000px grid, and 200px with no horizontal scrollbar after the grid shrinks to 400pxminWidth="300px"grows to 1000px when the grid widens from 400px to 1200pxThe last 2 also fail on the previous commit of this PR. They cover the regression found in review.
Regression: all 83 grid spec files (3,676 tests) pass, and
npm run lint:libreports no errors. Also checked in the demo app: the #18039 tab pins and unpins the column, and in a local sample with the two cases from review, the columns follow the grid width.Test Configuration:
Screenshots / Recordings
N/A
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)