Skip to content

fix: finish silent initial-scroll retries on their current target - #604

Open
chrispader wants to merge 2 commits into
LegendApp:mainfrom
chrispader:fix/native-initial-scroll-target
Open

chrispader wants to merge 2 commits into
LegendApp:mainfrom
chrispader:fix/native-initial-scroll-target

Conversation

@chrispader

@chrispader chrispader commented Nov 9, 2026 •

Copy link
Copy Markdown

When an Android initial scroll dispatches without a native scroll event, the completion fallback retries it by nudging the offset one point away and returning to the target on the next frame. If another completion check finished the scroll first, the return frame was cancelled and the list stayed one point off its target. The return also reissued the offset recorded before the nudge, even when adjustments had moved the target in the meantime. With this change, finishing a scroll runs a pending return first, and the return reads the current target.

This builds on #600, which makes adjustments move the target of an in-flight initial scroll. Until #600 lands, this PR also shows its commit, and only the last commit belongs here. The deferred-adjustment fix this PR used to contain moved to #600, since both changed the same callback.

We hit this in Expensify/App#100733, which moves the chat message list to LegendList. Expensify currently carries this fix as a patch.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T13:13:40.253835Z
We couldn’t complete this review. Comment @codex review to try again.
a3adce7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

chrispader added a commit to margelo/Expensify that referenced this pull request Nov 9, 2026
On Android, a chat opened at a linked message appeared with the message at the top of the list and then moved down to its offset. LegendList applied the native anchor adjustments for rows measured during its initial scroll a second time, and its retries reused a stale target. Patch LegendList to skip anchor moves a later native scroll already includes, move the pending target with each adjustment, and finish its silent-scroll retry before the scroll completes (LegendApp/legend-list#604).

The list also requested older actions from scroll events that arrive before the initial scroll lands, which inserted a page above the linked message while it was being positioned. Older actions now load from scroll events only once the list is ready.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrispader added a commit to margelo/Expensify that referenced this pull request Nov 9, 2026
Before a list is ready, LegendList moved its native anchor a frame after the positions changed, so an initial scroll dispatched in between was shifted a second time, and retries reused a stale target. Patch LegendList as proposed upstream in LegendApp/legend-list#604.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrispader and others added 2 commits November 11, 2026 12:31
…list

Before the list is ready, requestAdjust moves state.scroll and the item
positions right away but applies the native scroll adjustment on the next
frame. Two things went wrong in between.

setInitialRenderState could mark the list ready before that frame ran, so the
containers became visible with items at the unadjusted offset and jumped once
the adjustment landed. Readiness now waits until every adjustment queued
before the list was ready has run, and the last one re-checks readiness. The
queued callback owns the adjustingFromInitialMount counter, so the Android
old-architecture workaround path releases it too.

A native initial scroll dispatched in that frame already targets the adjusted
offset, so moving the anchor afterwards shifted the list a second time. A
deferred adjustment is now skipped when an absolute native scroll was issued
after it was requested. The in-flight native initial scroll target also moves
with each adjustment, so completion retries reissue the current offset
instead of the one recorded at dispatch. Web retargets from the index and is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an Android initial scroll dispatches without a native scroll event, the
completion fallback retries it by nudging the offset one point away and
returning to the target on the next frame. Two things could leave the list
off its target.

Another completion check could finish the scroll before the return frame ran.
Finishing cancelled the frame, so the list stayed one point away from its
target. Finishing now runs a pending return first.

The return also reissued the offset recorded before the nudge. Adjustments
that land in between move the target (LegendApp#600), so the return now reads the
watchdog's current target offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrispader
chrispader force-pushed the fix/native-initial-scroll-target branch from a3adce7 to 0eb9e97 Compare November 11, 2026 12:15
@chrispader chrispader changed the title fix: keep native initial scrolls on their current target fix: finish silent initial-scroll retries on their current target Nov 11, 2026
chrispader added a commit to margelo/Expensify that referenced this pull request Nov 12, 2026
Each LegendList patch is now the build output of its upstream PR, so the
patches change exactly what the PRs change, in every bundle the PRs touch.

- 001 and 003 now also patch the native bundles, as their PRs change shared
  code.
- 002 adds the explicit maintainVisibleContentPosition anchor option that
  LegendApp/legend-list#597 now proposes, instead of anchoring the last
  visible item in every list with alignItemsAtEnd.
- 004 contains LegendApp/legend-list#600, which now also skips deferred
  adjustments that a later native scroll already includes and moves the
  initial scroll target with each adjustment.
- 006 keeps only the silent-retry fix from LegendApp/legend-list#604.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant