Skip to content

feat: let maintainVisibleContentPosition keep the last visible item in place - #597

Open
chrispader wants to merge 1 commit into
LegendApp:mainfrom
chrispader:fix/anchor-end-aligned-lists
Open

chrispader wants to merge 1 commit into
LegendApp:mainfrom
chrispader:fix/anchor-end-aligned-lists

Conversation

@chrispader

@chrispader chrispader commented Nov 4, 2026 •

Copy link
Copy Markdown

MVCP keeps the first visible item in place when items resize or data changes. Chat-style lists are read from the bottom, so when an item near the top of the viewport changes height, every item below it moves. A common case is the oldest loaded message losing its author header after older messages from the same author load. This adds anchor: "end" to maintainVisibleContentPosition, which keeps the last visible item in place instead, like an inverted list.

<LegendList alignItemsAtEnd maintainVisibleContentPosition={{ data: true, anchor: "end" }} {...props} />

// The viewport shows item-2 and item-3, and item-2 shrinks by 50px.
// anchor "start" (default): item-2 stays, and item-3 moves up by 50px.
// anchor "end": item-3 stays, and the list scrolls by -50px.

An earlier version of this PR tied the behavior to alignItemsAtEnd. It is an explicit option now, so lists that only use alignItemsAtEnd to pin short content keep their current anchoring, and the default stays "start".

We need this for Expensify/App#100733, which moves the chat message list to LegendList. Expensify currently carries this change as a patch.

Reproduction

  1. Render a list with maintainVisibleContentPosition={{ anchor: "end" }}, scrolled so that several items are visible.
  2. Shrink the height of the first visible item.
  3. Verify the last visible item stays in place and only the content above it moves.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-04T20:45:07.717337Z
We couldn’t complete this review. Comment @codex review to try again.
5b488c9 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.

…n place

prepareMVCP always keeps the first visible item in place, so a size or data
change moves the content below it. Chat-style lists are read from the bottom
and need the opposite. For example, when older messages load and the oldest
loaded message loses its sender header, it shrinks, and every message below
it moves up.

maintainVisibleContentPosition now accepts anchor: "start" | "end". With
"end", the last visible item stays in place for size changes and is tried
first among the fallback anchors for data changes, so changes only move the
content above it, like in an inverted list. "start" stays the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrispader
chrispader force-pushed the fix/anchor-end-aligned-lists branch from 141508e to ff4a88f Compare November 11, 2026 12:14
@chrispader chrispader changed the title fix: anchor the last visible item in end-aligned lists feat: let maintainVisibleContentPosition keep the last visible item in place 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>
chrispader added a commit to margelo/Expensify that referenced this pull request Nov 12, 2026
LegendList patch 002 now follows LegendApp/legend-list#597, which makes
anchoring the last visible item an explicit maintainVisibleContentPosition
option instead of deriving it from alignItemsAtEnd. The chat list passes
anchor "end" whenever it aligns its messages to the end, so rows that resize
or load above the reader's position keep moving only the content above it.

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