Fix scroll progress bar showing 100% with no overflow#3652
Open
mattgperry wants to merge 1 commit intomainfrom
Open
Fix scroll progress bar showing 100% with no overflow#3652mattgperry wants to merge 1 commit intomainfrom
mattgperry wants to merge 1 commit intomainfrom
Conversation
When a scroll container has no overflow (scrollHeight === clientHeight), scrollLength is 0. The progress() utility returns 1 for a zero range, causing scroll progress to immediately report 100% instead of 0%. This guards against the zero scrollLength case in updateAxisInfo, returning 0 progress when there is nothing to scroll. Fixes #2950 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a bug where a scroll progress bar would immediately report 100% progress when a scroll container has no overflow ( Key changes:
Minor observation:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[updateAxisInfo called] --> B["Compute scrollLength\n(scrollHeight - clientHeight)"]
B --> C{scrollLength === 0?}
C -- "Yes (no overflow)" --> D["axis.progress = 0\n✅ Bug fixed"]
C -- "No (has overflow)" --> E["axis.progress = progress(0, scrollLength, current)\n✅ Normal path"]
E --> F["progress utility\nreturns value / scrollLength"]
D --> G[Scroll info emitted to consumer]
F --> G
style D fill:#d4edda,stroke:#28a745
style C fill:#fff3cd,stroke:#ffc107
Last reviewed commit: c404206 |
Comment on lines
+439
to
+440
| expect(latest.y.scrollLength).toEqual(0) | ||
| expect(latest.y.progress).toEqual(0) |
There was a problem hiding this comment.
The fix in updateAxisInfo applies to both the x and y axes, but the test only asserts latest.y. Consider also asserting latest.x.scrollLength and latest.x.progress to give symmetric coverage of the guard:
Suggested change
| expect(latest.y.scrollLength).toEqual(0) | |
| expect(latest.y.progress).toEqual(0) | |
| expect(latest.y.scrollLength).toEqual(0) | |
| expect(latest.y.progress).toEqual(0) | |
| expect(latest.x.scrollLength).toEqual(0) | |
| expect(latest.x.progress).toEqual(0) |
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.
Summary
progress()utility returns1for a zero-width range (progress(0, 0, 0) === 1), which is correct for animations (zero-duration = complete) but wrong for scroll (no overflow = nothing scrolled)updateAxisInfoto return0progress whenscrollLengthis0Fixes #2950
Test plan
progressreturns1→ 100%)yarn testpassesyarn buildsucceeds🤖 Generated with Claude Code