Skip to content

docs: add workaround for non-working scrollToEnd#1392

Merged
kirillzyusko merged 2 commits intomainfrom
docs/scroll-to-end-does-not-work
Apr 1, 2026
Merged

docs: add workaround for non-working scrollToEnd#1392
kirillzyusko merged 2 commits intomainfrom
docs/scroll-to-end-does-not-work

Conversation

@kirillzyusko
Copy link
Copy Markdown
Owner

@kirillzyusko kirillzyusko commented Mar 23, 2026

📜 Description

Added workaround for non-working scrollToEnd method for virtualized lists.

💡 Motivation and Context

This code in FlatList causes a problem:

  // scrollToEnd may be janky without getItemLayout prop
  scrollToEnd(params?: ?{animated?: ?boolean, ...}) {
    const animated = params ? params.animated : true;
    const veryLast = this.props.getItemCount(this.props.data) - 1;
    if (veryLast < 0) {
      return;
    }
    const frame = this._listMetrics.getCellMetricsApprox(veryLast, this.props);
    const offset = Math.max(
      0,
      frame.offset +
        frame.length +
        this._footerLength -
        this._scrollMetrics.visibleLength,
    );

    // TODO: consider using `ref.scrollToEnd` directly
    this.scrollToOffset({animated, offset});
  }

So this function doesn't consider keyboard offset and because of that scrolls to wrong offset when keyboard is shown.

In this PR I explained how to pass a ref directly to underlying ScrollView and use scrollToEnd of ScrollView level. Additionally in example project I started to use it as well.

Closes #1357

📢 Changelog

JS

  • pass scrollRef to VirtualizedList in example appl
  • use scrollTo from ScrollView ref;

Docs

  • added a new item to troubleshooting guide;

🤔 How Has This Been Tested?

Tested manually in exampel app (paper/fabric).

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Mar 23, 2026
@kirillzyusko kirillzyusko added the documentation Improvements or additions to documentation label Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 23, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-01 13:39 UTC

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 changed Mar 25, 2026, 7:34 PM

@kirillzyusko kirillzyusko added the KeyboardChatScrollView 💬 Anything about chat functionality label Mar 25, 2026
@kirillzyusko kirillzyusko marked this pull request as ready for review April 1, 2026 13:36
@kirillzyusko kirillzyusko merged commit 10c0218 into main Apr 1, 2026
19 of 20 checks passed
@kirillzyusko kirillzyusko deleted the docs/scroll-to-end-does-not-work branch April 1, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation KeyboardChatScrollView 💬 Anything about chat functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[1.21.0-beta.3] .scrollToEnd doesn't work

1 participant