Repository navigation
Clamp section scroll offset to the scrollable range - #22741
Draft
francisrath wants to merge 4 commits into
Draft
francisrath wants to merge 4 commits into
francisrath wants to merge 4 commits into
Conversation
A scrollTop saved while the Changes list was longer is replayed through setScrollTop on the History -> Changes transition. Clamping it to the section's total height rather than its scrollable range let it land at or past the end of the content, which react-virtualized resolves to a visible range of just the final row, so the list renders one row at the bottom of an empty pane. A grid shorter than its viewport never scrolls, so no scroll event ever fires to correct the offset. Fixes desktop#22619
…list-stale-scroll-offset
The clamp and the grid's height prop computed the same value separately. Sharing it makes it plain that the offset is clamped to what this grid can actually scroll. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 task done
This branch has not been deployed
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.
Closes #22619
Description
The Changes list could render a single row at the bottom of an otherwise empty pane while the header still reported the correct file count. The rows aren't drawn blank — they're never rendered at all, so there's nothing to click or uncheck, while the header count, the select-all checkbox and the commit button all still act on the full set.
setScrollToprestores a scroll position saved while the list was longer —repository.tsxpasseschangesListScrollTopback on the History → Changes transition.getSectionGridRendererclamped that offset to the section's total height rather than to its scrollable range, so a restored position could land at or past the end of the content. react-virtualized resolves an offset past the end to a visible range of just the final row (_findNearestCellclamps tocellCount - 1, and thestoploop can't advance past it).Nothing corrects it afterwards: a grid shorter than its viewport never scrolls, so no scroll event arrives to run react-virtualized's own clamp, and
SectionList.onScrollstores the value unclamped and hands it back up to be saved again. That's also why switching to History and back doesn't help — that transition is what restores the offset in the first place.Clamping to
sectionHeight - visibleHeightyields0for a section that fits its viewport, so every row renders regardless of what was restored. For a section taller than the viewport the clamp only ever renders a superset of what's visible, so scrolling is unaffected.Reproducing it (5/5 on 3.6.3, macOS):
Step 2 is the necessary ingredient — the identical sequence without scrolling first renders correctly every time, which I ran as a control. #22619 has a script that automates this.
Verified against a build of this branch. Where 3.6.3 renders one row, this renders all of them: 60→5, 40→3, 80→12 and 30→2. The stale offset is still being restored on the patched build (1319, 739, 1899, 449 before each transition), so the clamp is what's doing the work rather than some side effect of rebuilding. Scrolling still tracks correctly: on a 60-row list in a 421px viewport, offset 0 draws rows 0-18, 400 draws 13-32, 900 draws 31-49, and the bottom draws 45-59 ending on the true final row.
I also checked whether the History list has the same defect, since
commit-list.tsxpassescompareListScrollTopintoListthe same way and its only reset (scrollCompareListToTop) fires just on branch-created-from-commit. It doesn't reproduce — planting a stalecompareListScrollTopand going Changes → History still renders every commit, because the commit list mounts empty while commits load and so passes throughrowCount === 0, which react-virtualized explicitly zeroes the scroll offset for.SectionList's root grid never does, since itsrowCountis the number of sections rather than the number of files.The test case is added alongside the existing #22387 one in
section-list-scroll-test.tsx: render aSectionListwith asetScrollToplarger than its content, assert every row renders. It fails without the fix (expected all 5 rows to render, got 1) and passes with it.Screenshots
The screenshot in #22619 shows the failure: "17 changed files" in the header, one row (
OrderSummary.vue) at the bottom of an empty pane, and "Commit 17 files" on the button. With this change all 17 rows render in place.Release notes
Notes: [Fixed] Show every changed file in the Changes list after returning from the History tab - #22619