Repository navigation
fix(MessageList): make older-page anchor restore idempotent on iOS WebKit - #3312
MartinCupela wants to merge 1 commit into
Conversation
β¦bKit restoreAnchor corrected the scroll position with a relative scrollBy based on getBoundingClientRect. On iOS WebKit the geometry read in the frame after a scroll still reflects the pre-scroll position, so every correction overshot and the loop flipped between two scroll positions until the 1200 ms timeout, leaving the list at an arbitrary position. Assign an absolute scrollTop derived from the anchor's layout offset (offsetTop, independent of the current scroll) so re-applying the correction cannot compound. Closes #3311 Closes REACT-1213 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the βοΈ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Size Change: +183 B (+0.02%) Total Size: 1.09 MB π¦ View Changed
βΉοΈ View Unchanged
|
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-v14 #3312 +/- ##
==============================================
Coverage ? 85.54%
==============================================
Files ? 512
Lines ? 16205
Branches ? 5128
==============================================
Hits ? 13863
Misses ? 2342
Partials ? 0 β View full report in Codecov by Harness. π New features to boost your workflow:
|
π― Goal
On iOS WebKit (Safari and Chrome iOS), loading an older page of messages in the non-virtualised
MessageListmoves the user away from the message they were reading, often to near the newest messages.Fixes #3311
Closes REACT-1213
π Implementation details
restoreAnchor(useScrollLocationLogic) corrected the scroll position every frame with a relativescrollBy({ top: offsetDelta }), whereoffsetDeltacame fromgetBoundingClientRect. On iOS WebKit the geometry read in the frame after a scroll still reflects the pre-scroll position, so each correction overshoots and the next frame measures the same error with the opposite sign. The loop flips between two positions until the 1200 ms settle timeout and leaves the list wherever it is at that moment.The restore now assigns an absolute
scrollTopderived from the anchor's layout offset (offsetTop, which does not depend on the current scroll position), so re-applying it on later frames cannot compound.getOffsetWithinsums theoffsetParentchain, so it does not assume the list is the anchor'soffsetParent.Verification, using the real
<MessageList>(25 messages, 25 older prepended while parked atscrollTop200). The anchor ends at the same viewport position it had when loading started (0 px drift), with noscrollBycalls and no sign flips, in: iOS 17.4 Safari (simulator), desktop Safari 26.2, Chrome 152, Firefox 157. Chrome and Firefox need no correction (native scroll anchoring). Before the fix, iOS 17.4 Safari ended with the anchor 3552 px away. Not tested on iOS 26 (the reporter's version).The existing "preserves the viewport when older messages are prependedβ¦" test now asserts an absolute
scrollTopand noscrollBy.Not covered here: on
master, the anchor restore is currently a no-op stub, so it needs a separate look when that is reconciled.π¨ UI Changes
None.