fix(MiddleRowFocus): preserve scroll anchor across table operations#756
Merged
lcottercertinia merged 1 commit intoMay 9, 2026
Merged
Conversation
Replace the always-recenter behavior with operation-aware scroll preservation, addressing four distinct symptoms: - Single tree expand/collapse no longer jumps to center: a one-shot skipNextRender flag is armed on the first toggle of a burst and cleared by a second toggle in the same tick, so single toggles preserve scrollTop while expand-all/collapse-all still recenters. - Column sort no longer scrolls to the top: the anchor is captured in the dataSorting pre-event instead of renderStarted, since Tabulator resets scrollTop before renderStarted fires for sort. - Filter no longer leaves a blank strip across the top of the table: detect the inflated .tabulator-table paddingTop left by Tabulator's rerenderRows desync (pre-filter vDomTop/vDomBottom against post-filter rows) and zero both paddingTop and renderer.vDomTopPad on the next frame. Upstream fix tracked in tabulator-virtual-scroll-fixes.md. - At-top / at-bottom no longer jumps off the edge: capture wasAtTop / wasAtBottom alongside the middle row using a 10px threshold, and on restore snap to scrollTop = 0 / scrollHeight - clientHeight instead of centering. Anchor capture/restore is consolidated behind \_captureAnchor / \_restoreAnchor / \_clearAnchor so future fields snapshot in one place. Add unit tests covering each path: single-toggle skip, bulk-toggle fall-through, dataSorting pre-capture, paddingTop reset (stale and legitimate), and at-top / at-bottom boundary snapping.
14 tasks
lcottercertinia
approved these changes
May 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 PR Overview
Improves row-focus behavior so the user's scroll position is preserved across table operations (sort, filter, single tree toggle) instead of always recentering on the middle visible row.
🛠️ Changes made
dataSorting(Tabulator resetsscrollTopbeforerenderStarted, so the previous capture point lost the pre-sort row).scrollTopstays put. Bulk toggles (expand-all / collapse-all) detect a synchronous burst and run the recenter as before.rerenderRowsleaves.tabulator-tablepaddingTopinflated — detect (scrollTop < paddingTop) and zero it plusvDomTopPadon the next frame.🧩 Type of change (check all applicable)
📷 Screenshots / gifs / video [optional]
n/a
🔗 Related Issues
fixes #
resolves #
closes #
related #
✅ Tests added?
📚 Docs updated?
Anything else we need to know? [optional]
The filter padding fix is a workaround in
MiddleRowFocusrather than a direct edit totabulator_esm.mjs. Seetabulator-virtual-scroll-fixes.md"Fix 7" for the related upstream patch context.