Skip to content

refactor: replace getHeadersWidth's out-of-range loop-index probe with hasFrozenColumns() - #2675

Merged
ghiscoding merged 2 commits into
masterfrom
bugfix/headers-width-oob-probe
Aug 3, 2026
Merged

refactor: replace getHeadersWidth's out-of-range loop-index probe with hasFrozenColumns()#2675
ghiscoding merged 2 commits into
masterfrom
bugfix/headers-width-oob-probe

Conversation

@ghiscoding

@ghiscoding ghiscoding commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Port bug fix from 6pac/SlickGrid PR 6pac/SlickGrid#1260 into slickgrid-universal

The quirk

getHeadersWidth()'s post-loop scrollbar attribution re-tested the loop variable after the loop ended — i === columns.length, an out-of-range index probe:

if ((this._options.frozenColumn!) > -1 && (i > this._options.frozenColumn!)) {
  this.headersWidthR += scrollbarWidth;   // i is columns.length here
}

This only happened to be equivalent to 'is a left freeze active' because setFrozenOptions clamps frozenColumn to < columns.length, making the second conjunct invariantly true whenever the first is — an accidental invariant a future refactor could silently break.

The change

State the intent directly with hasFrozenColumns() and scope the loop variable into the loop so the accidental dependency cannot recur. Zero behavior change for every reachable state (equivalence follows from the setFrozenOptions clamp).

Per the triage discussion this PR deliberately does not touch the double scrollbar addition further down in the same function (headersWidthR/L get the scrollbar added again in the band-finalization block) — that one has potential pixel-visible effects and deserves its own investigation.

Why no repro/test

Nothing observable changes — there is no symptom to pin. Width-sensitive suites (frozen-columns-and-rows, example1, auto-resize) ran 18/18 green as a regression gate.

(Part of the quirks-triage series:
6pac/SlickGrid#1255
6pac/SlickGrid#1256
6pac/SlickGrid#1257
6pac/SlickGrid#1258
6pac/SlickGrid#1259

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (15d9833) to head (116fc3b).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2675   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         200      200           
  Lines       25452    25461    +9     
  Branches     8999     9000    +1     
=======================================
+ Hits        25452    25461    +9     
Flag Coverage Δ
angular 100.0% <ø> (ø)
universal 100.0% <100.0%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Jul 29, 2026

Copy link
Copy Markdown
angular-slickgrid

npm i https://pkg.pr.new/angular-slickgrid@2675

aurelia-slickgrid

npm i https://pkg.pr.new/aurelia-slickgrid@2675

slickgrid-react

npm i https://pkg.pr.new/slickgrid-react@2675

slickgrid-vue

npm i https://pkg.pr.new/slickgrid-vue@2675

@slickgrid-universal/angular-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/angular-row-detail-plugin@2675

@slickgrid-universal/aurelia-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/aurelia-row-detail-plugin@2675

@slickgrid-universal/react-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/react-row-detail-plugin@2675

@slickgrid-universal/vue-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/vue-row-detail-plugin@2675

@slickgrid-universal/binding

npm i https://pkg.pr.new/@slickgrid-universal/binding@2675

@slickgrid-universal/common

npm i https://pkg.pr.new/@slickgrid-universal/common@2675

@slickgrid-universal/composite-editor-component

npm i https://pkg.pr.new/@slickgrid-universal/composite-editor-component@2675

@slickgrid-universal/custom-footer-component

npm i https://pkg.pr.new/@slickgrid-universal/custom-footer-component@2675

@slickgrid-universal/custom-tooltip-plugin

npm i https://pkg.pr.new/@slickgrid-universal/custom-tooltip-plugin@2675

@slickgrid-universal/empty-warning-component

npm i https://pkg.pr.new/@slickgrid-universal/empty-warning-component@2675

@slickgrid-universal/event-pub-sub

npm i https://pkg.pr.new/@slickgrid-universal/event-pub-sub@2675

@slickgrid-universal/excel-export

npm i https://pkg.pr.new/@slickgrid-universal/excel-export@2675

@slickgrid-universal/graphql

npm i https://pkg.pr.new/@slickgrid-universal/graphql@2675

@slickgrid-universal/odata

npm i https://pkg.pr.new/@slickgrid-universal/odata@2675

@slickgrid-universal/pagination-component

npm i https://pkg.pr.new/@slickgrid-universal/pagination-component@2675

@slickgrid-universal/pdf-export

npm i https://pkg.pr.new/@slickgrid-universal/pdf-export@2675

@slickgrid-universal/row-detail-view-plugin

npm i https://pkg.pr.new/@slickgrid-universal/row-detail-view-plugin@2675

@slickgrid-universal/rxjs-observable

npm i https://pkg.pr.new/@slickgrid-universal/rxjs-observable@2675

@slickgrid-universal/sql

npm i https://pkg.pr.new/@slickgrid-universal/sql@2675

@slickgrid-universal/text-export

npm i https://pkg.pr.new/@slickgrid-universal/text-export@2675

@slickgrid-universal/utils

npm i https://pkg.pr.new/@slickgrid-universal/utils@2675

@slickgrid-universal/vanilla-bundle

npm i https://pkg.pr.new/@slickgrid-universal/vanilla-bundle@2675

@slickgrid-universal/vanilla-force-bundle

npm i https://pkg.pr.new/@slickgrid-universal/vanilla-force-bundle@2675

@slickgrid-universal/web-mcp

npm i https://pkg.pr.new/@slickgrid-universal/web-mcp@2675

commit: 116fc3b

@ghiscoding ghiscoding added the AI label Jul 29, 2026
@ghiscoding
ghiscoding merged commit 531b61d into master Aug 3, 2026
22 checks passed
@ghiscoding
ghiscoding deleted the bugfix/headers-width-oob-probe branch August 3, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant