Skip to content

fix(grid): prevent NaN column width when hidden grid has all columns sized - 22.0.x - #17461

Merged
ChronosSF merged 2 commits into
22.0.xfrom
vkombov/fix-17418-22.0.x
Jul 30, 2026
Merged

fix(grid): prevent NaN column width when hidden grid has all columns sized - 22.0.x#17461
ChronosSF merged 2 commits into
22.0.xfrom
vkombov/fix-17418-22.0.x

Conversation

@viktorkombov

Copy link
Copy Markdown
Contributor

Closes #17418

Description

getPossibleColumnWidth() divided the available width by columnsToSize when every visible column already had an explicit or constrained width.

When the grid is hidden through a wrapper and has no measurable width, calcWidth falls back to the sum of the column widths. In this case, computedWidth equals sumExistingWidths and columnsToSize is 0, resulting in 0 / 0 = NaN. This then poisons the cached column widths and can cause an infinite sizing loop.

When the grid is using the column-width sum fallback and there are no columns left to auto-size, return the "0px" sentinel so the existing valid column widths are preserved.

Motivation / Context

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copilot AI review requested due to automatic review settings July 24, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a grid autosizing edge case where getPossibleColumnWidth() could return NaNpx when the grid is hidden (no measurable width) and all visible columns already have explicit/constrained widths, which can poison cached widths and lead to repeated sizing/reflow.

Changes:

  • Add a guard in getPossibleColumnWidth() to return the "0px" sentinel in the problematic hidden-grid/sum-width fallback scenario.
  • Add a unit test reproducing the hidden-wrapper case and asserting no NaN widths are derived.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
projects/igniteui-angular/grids/grid/src/grid-base.directive.ts Adds an early-return guard to prevent NaN possible widths when the grid width is derived from summing column widths.
projects/igniteui-angular/grids/grid/src/column.spec.ts Adds a regression test that hides the grid via a wrapper and verifies derived widths remain finite.

Comment thread projects/igniteui-angular/grids/grid/src/grid-base.directive.ts
@ChronosSF ChronosSF assigned ChronosSF and unassigned dkamburov and damyanpetev Jul 30, 2026
@ChronosSF
ChronosSF requested a review from rkaraivanov July 30, 2026 08:28
@ChronosSF ChronosSF added ✅ status: verified Applies to PRs that have passed manual verification and removed ❌ status: awaiting-test PRs awaiting manual verification labels Jul 30, 2026
@ChronosSF
ChronosSF merged commit 666e563 into 22.0.x Jul 30, 2026
6 checks passed
@ChronosSF
ChronosSF deleted the vkombov/fix-17418-22.0.x branch July 30, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

grid version: 22.0.x ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants