Skip to content

fix(core): compute scrollTo page before deriving the paging offset#2644

Merged
ghiscoding merged 1 commit into
masterfrom
bugfix/scrollto-page-offset-order
Jul 13, 2026
Merged

fix(core): compute scrollTo page before deriving the paging offset#2644
ghiscoding merged 1 commit into
masterfrom
bugfix/scrollto-page-offset-order

Conversation

@ghiscoding

Copy link
Copy Markdown
Owner

Apply fix from 6pac repo's

Problem

In scrollTo(y) the virtual-scrolling offset is derived from the previous page before the page is updated for the target position:

this.offset = Math.round(this.page * (this.cj || 0));                       // uses the page from BEFORE this scroll
this.page = Math.min((this.n || 0) - 1, Math.floor(y / (this.ph || 0)));   // page updated too late

So after a programmatic jump that crosses pages (scrollRowToTop, scrollRowIntoView, updateRowCount's scroll restoration) the page/offset pair lags one scroll event behind, and the first render after the jump runs with the old page's offset. Reproduced on a 1.5M-row grid (paging engaged, n = 117): after scrollRowToTop(750000) the grid reported page: 58 with offset: 0 until the next scroll event corrected it.

This only affects grids tall enough to enter paging mode (content beyond maxSupportedCssHeight); everything self-corrects on the next scroll event, which is why it goes unnoticed in normal wheel/drag scrolling.

Fix

Restore the original SlickGrid order — compute the page for the target position first, then derive the offset from that page. Also replaces the y / (this.ph || 0) division (which relies on Math.min to mop up the resulting Infinity) with an explicit ph guard.

Verification

  • 1.5M-row grid, jumps to rows 750k / 0 / 1.49M / 400k: immediately after each scrollRowToTop, offset === Math.round(page * cj) and page === floor(y / ph) now hold (previously the offset was one event stale).
  • Full Cypress suite passes.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (e18dfa1) to head (3a2f0ee).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2644   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         200      200           
  Lines       25317    25317           
  Branches     8951     8951           
=======================================
  Hits        25317    25317           
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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 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 13, 2026

Copy link
Copy Markdown
angular-slickgrid

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

aurelia-slickgrid

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

slickgrid-react

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

slickgrid-vue

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

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

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

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

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

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

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

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

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

@slickgrid-universal/binding

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

@slickgrid-universal/common

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

@slickgrid-universal/composite-editor-component

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

@slickgrid-universal/custom-footer-component

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

@slickgrid-universal/custom-tooltip-plugin

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

@slickgrid-universal/empty-warning-component

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

@slickgrid-universal/event-pub-sub

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

@slickgrid-universal/excel-export

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

@slickgrid-universal/graphql

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

@slickgrid-universal/odata

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

@slickgrid-universal/pagination-component

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

@slickgrid-universal/pdf-export

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

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

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

@slickgrid-universal/rxjs-observable

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

@slickgrid-universal/sql

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

@slickgrid-universal/text-export

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

@slickgrid-universal/utils

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

@slickgrid-universal/vanilla-bundle

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

@slickgrid-universal/vanilla-force-bundle

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

@slickgrid-universal/web-mcp

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

commit: 3a2f0ee

@ghiscoding
ghiscoding merged commit a944424 into master Jul 13, 2026
12 checks passed
@ghiscoding
ghiscoding deleted the bugfix/scrollto-page-offset-order branch July 13, 2026 14:33
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