Skip to content

[scroll area] Add overscroll feedback to the scrollbar thumb - #5145

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:claude/determined-pascal-31f175
Jul 10, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:claude/determined-pascal-31f175

Conversation

@atomiks

@atomiks atomiks commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4682

In Safari/WebKit, overscroll any scroll area (left sidebar, or the demos): https://deploy-preview-5145--base-ui.netlify.app/react/components/scroll-area

Summary

Adds native-style overscroll feedback to the Scroll Area scrollbar: while the viewport rubber-bands past an edge, the thumb shrinks against that edge instead of staying pinned at full size, mirroring the macOS native scrollbar behavior shown in the issue.

Details

computeThumbPosition already had to clamp away the rubber-band, since Safari is the only engine that reports an out-of-range scrollTop/scrollLeft. Instead of discarding that value, it now drives the shrink:

  • The overscroll distance is scrollPos - clamp(scrollPos, 0, maxScroll) — 0 on every engine except Safari (Chrome/Firefox clamp the scroll position), so this is a no-op elsewhere.
  • The thumb's height/width shrinks by the overscroll amount (floored at MIN_THUMB_SIZE) and stays pinned to the overscrolled edge.
  • The horizontal case measures from the inline-start edge, so the same math covers LTR and RTL with a single sign flip on the final translate.

The size change is applied via height/width rather than a scaleY/scaleX transform, so rounded thumb caps stay round during the overscroll.

Testing

The overscroll path is only reachable in Safari — jsdom has no layout and Chromium clamps the scroll position on assignment, so it can't be exercised in CI. Verified manually in Safari (vertical + horizontal, rounded thumb, both edges). The in-range behavior is unchanged and remains covered by the existing Chromium test suite.

@atomiks atomiks added type: new feature Expand the scope of the product to solve a new problem. component: scroll area Changes related to the scroll area component. labels Jun 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5145
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5145
    

commit: 4cd1c28

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+162B(+0.03%) 🔺+55B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,361.27 ms +162.99 ms(+13.6%) | Renders: 78 (+0)

Test Duration Renders
Scroll Area mount (300 instances) 141.17 ms 🔺+53.09 ms(+60.3%) 3 (+0)
Menu open (500 items) 100.67 ms 🔺+34.85 ms(+53.0%) 12 (+0)
Mixed surface mount (app-like density) 93.49 ms 🔺+20.77 ms(+28.6%) 5 (+0)
Checkbox mount (500 instances) 76.23 ms 🔺+14.03 ms(+22.6%) 1 (+0)
Select open (500 options) 59.18 ms 🔺+11.22 ms(+23.4%) 14 (+0)

…and 1 more (+8 within noise) — details

Metric alarms

Test Metric Change
Scroll Area mount (300 instances) bench:paint 🔺 +55.11 ms
Menu open (500 items) bench:paint 🔺 +61.43 ms
Menu open (500 items) bench:paint#menu-open 🔺 +61.43 ms
Mixed surface mount (app-like density) bench:paint 🔺 +26.78 ms
Select open (500 options) bench:paint 🔺 +21.37 ms
Select open (500 options) bench:paint#select-open 🔺 +21.37 ms
Combobox type — 500 items, all stay mounted (type "Row ") bench:paint#combobox-open 🔺 +12.90 ms
Combobox type — 500 items, all stay mounted (type "Row ") bench:paint 🔺 +12.90 ms

Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 4cd1c28
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a44c1b0f0a56900089fd2ef
😎 Deploy Preview https://deploy-preview-5145--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. browser: Safari Affects or fixes behavior in Apple Safari. and removed type: new feature Expand the scope of the product to solve a new problem. labels Jul 1, 2026
@atomiks
atomiks force-pushed the claude/determined-pascal-31f175 branch 4 times, most recently from 07afe64 to 12a7ea4 Compare July 1, 2026 06:54
@atomiks
atomiks force-pushed the claude/determined-pascal-31f175 branch from 12a7ea4 to 4cd1c28 Compare July 1, 2026 07:28
@atomiks
atomiks marked this pull request as ready for review July 1, 2026 07:34
@atomiks
atomiks merged commit df156eb into mui:master Jul 10, 2026
6 checks passed
@atomiks
atomiks deleted the claude/determined-pascal-31f175 branch July 10, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

browser: Safari Affects or fixes behavior in Apple Safari. component: scroll area Changes related to the scroll area component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scroll area] Support overscroll feedback (shrink)

1 participant