Skip to content

fix: frozen-bottom hit testing resolves the wrong row when data is shorter than the viewport - #2673

Merged
ghiscoding merged 1 commit into
masterfrom
bugfix/frozen-bottom-hit-testing
Aug 3, 2026
Merged

fix: frozen-bottom hit testing resolves the wrong row when data is shorter than the viewport#2673
ghiscoding merged 1 commit into
masterfrom
bugfix/frozen-bottom-hit-testing

Conversation

@ghiscoding

@ghiscoding ghiscoding commented Jul 29, 2026

Copy link
Copy Markdown
Owner

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

The bug

In frozenBottom mode, getCellFromEvent() and setActiveCellInternal() computed the bottom-canvas row offset from a live measurement of the top canvas:

rowOffset = (this._options.frozenBottom) ? Utils.height(this._canvasTopL) as number : this.frozenRowsHeight;

But the render path places bottom-canvas rows using getFrozenRowOffset(). The two diverge whenever the dataset is shorter than the viewport, because updateRowCount floors the body canvas height at the viewport height:

this.th = Math.max(scrollableRowsHeight, tempViewportH - scrollbarH);

Utils.height(this._canvasTopL, this.h);   // ≈ viewport height, not content height

So with e.g. 8 rows × 25px in a 500px container, the live measurement reads ~443px while the rows were placed with a 175px offset — clicking the frozen bottom row resolves to a row ~10 rows away (wrong getCellFromEvent result, wrong active cell).

The fix

Both call sites now use getFrozenRowOffset(this.actualFrozenRow) — the exact offset the render path used to place the row (hit-testing must invert rendering, not re-measure). For the top-freeze branch this is behavior-identical: getFrozenRowOffset returns frozenRowsHeight there.

Repro

{ frozenRow: 1, frozenBottom: true }, 8 rows, 500px-tall container → click the frozen bottom row → pre-fix getCellFromEvent returns a wrong row (e.g. 17 instead of 7).

Test

cypress/e2e/quirk-frozen-bottom-hit-testing.cy.ts — the repro page synthesizes clicks at real cell rects (frozen-bottom row, a body row, and a top-freeze control grid to guard the unchanged branch) and asserts getCellFromEvent resolves the correct rows. Verified to fail pre-fix and pass post-fix; frozen + editing suites ran 28/28 as a regression gate (the fix touches the active-cell path).

@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 (d4051b1).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2673   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         200      200           
  Lines       25452    25452           
  Branches     8999     8997    -2     
=======================================
  Hits        25452    25452           
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@2673

aurelia-slickgrid

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

slickgrid-react

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

slickgrid-vue

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

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

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

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

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

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

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

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

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

@slickgrid-universal/binding

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

@slickgrid-universal/common

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

@slickgrid-universal/composite-editor-component

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

@slickgrid-universal/custom-footer-component

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

@slickgrid-universal/custom-tooltip-plugin

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

@slickgrid-universal/empty-warning-component

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

@slickgrid-universal/event-pub-sub

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

@slickgrid-universal/excel-export

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

@slickgrid-universal/graphql

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

@slickgrid-universal/odata

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

@slickgrid-universal/pagination-component

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

@slickgrid-universal/pdf-export

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

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

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

@slickgrid-universal/rxjs-observable

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

@slickgrid-universal/sql

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

@slickgrid-universal/text-export

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

@slickgrid-universal/utils

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

@slickgrid-universal/vanilla-bundle

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

@slickgrid-universal/vanilla-force-bundle

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

@slickgrid-universal/web-mcp

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

commit: d4051b1

@ghiscoding ghiscoding added the AI label Jul 29, 2026
@ghiscoding
ghiscoding merged commit 656fe48 into master Aug 3, 2026
15 checks passed
@ghiscoding
ghiscoding deleted the bugfix/frozen-bottom-hit-testing branch August 3, 2026 16:43
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