Repository navigation
fix(ScrollArea): clear scrollbar registration on unmount so corner stays in sync - #2670
Conversation
…ays in sync ScrollAreaScrollbarX/Y registered their element into the root context on mount but never cleared it on unmount. Radix's React original does this via a ref-callback that fires with the node on mount and `null` on unmount; the Vue port dropped the unmount half. With type="hover" the scrollbars mount/unmount every hover cycle. Because scrollbarX/scrollbarY were never reset, the corner's visibility condition stayed true after the first leave, so ScrollAreaCornerImpl never unmounted. Its ResizeObserver is bound to the scrollbar element captured once at setup, so on the second hover the corner pointed at a detached element and failed to re-render. Add onUnmounted cleanup in both scrollbars to reset the registration. Fixes #2669 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes a reactivity bug where ChangesScrollArea Corner Hover State
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Fixes #2669
Problem
With
type="hover"and both scrollbars enabled, theScrollAreaCornersyncs correctly on the first hover cycle but permanently disappears from the second cycle onward.Root cause
ScrollAreaScrollbarX/Yregister their element into the root context on mount but never clear it on unmount:Radix's React original does this via a ref-callback, which fires with the node on mount and
nullon unmount. The Vue port dropped the unmount half.Since hover mounts/unmounts the scrollbars each cycle,
scrollbarX/scrollbarYstayed truthy after the first leave, so the corner's condition!!scrollbarX.value && !!scrollbarY.valuenever went false andScrollAreaCornerImplnever unmounted. ItsResizeObserveris bound to the scrollbar element captured once at setup, so on the second hover the corner pointed at a now-detached element and failed to re-render — the "stuck at false on cycle 2" reported in the issue.Fix
Add
onUnmountedcleanup in both scrollbars to reset the registration, mirroring the React ref-callback semantics. The corner now unmounts with the scrollbars on leave and re-mounts fresh (re-binding its observer to the live element) on each enter.Tests
Added a regression test in
ScrollArea.test.tsthat drives two hover cycles on a both-scrollbars + corner setup. It fails before the fix (corner stuck mounted after leave) and passes after. Full core suite passes (1642 passed, 3 skipped).🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests