Skip to content

fix: prevent negative flex-mode column widths from breaking CSS grid - #2293

Closed
surya-pabbineedi wants to merge 1 commit into
product-syncfrom
fix/flex-mode-negative-column-widths
Closed

fix: prevent negative flex-mode column widths from breaking CSS grid#2293
surya-pabbineedi wants to merge 1 commit into
product-syncfrom
fix/flex-mode-negative-column-widths

Conversation

@surya-pabbineedi

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

In flex mode, scaleColumns can leave a column width slightly (float noise) or largely (minWidth starvation) negative. In v25+, those widths are written into CSS grid-template-columns / --ngx-datatable-grid-template-columns. A negative track invalidates the whole declaration, so the browser falls back to a single column: headers stack and body cells overlap.

What is the new behavior?

  • scaleColumns clamps widths with Math.max(0, …) (same guard as forceFillColumnWidths)
  • Leftover delta is only applied to flexGrow > 0 columns that can absorb it without going negative
  • gridColumnTrack also clamps so negative values never reach CSS even if math regresses

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

Minimal fix only—no flexGrow-0 semantic change. Unit tests cover float/minWidth starvation cases, locked+flex distribution, and non-negative grid track strings.

Made with Cursor

Negative leftover delta in scaleColumns could produce widths < 0, which
invalidates grid-template-columns in v25+ and collapses the layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant