Skip to content

Bug Report: Editor does not auto-scroll until manually scrolled to bottom once #416

@dipakluhar

Description

@dipakluhar
screen-20250905-163803.mp4

Environment

Library: react-native-pell-rich-editor (RichEditor + RichToolbar)

Platform: Android (reproduced on Android 13 / 14 / 15)

React Native version: [your RN version here]

Device/Emulator: [device/emulator details]

Current Behavior

  • When typing inside the RichEditor, the cursor and text input area do not auto-scroll into view if the content grows beyond the visible area.
  • Initially, when the editor is empty or only has a small amount of text, typing works fine.
  • Once enough content is added to require scrolling, the cursor goes behind the keyboard or toolbar, and the editor does not auto-scroll.
  • Auto-scroll only starts working after I manually scroll the editor all the way down once.
  • After that first manual scroll, further typing scrolls correctly.

Expected Behavior

The editor should auto-scroll the cursor into view immediately, without requiring any manual scroll.
Typing in a new line at the bottom should always bring the cursor into view, even when the editor is freshly mounted.

Steps to Reproduce

  • Mount RichEditor inside a scrollable container (ScrollView / KeyboardAvoidingView).
  • Type enough lines so that the cursor moves below the visible area.
  • Observe: The cursor goes under the keyboard, and the editor does not auto-scroll.
  • Manually scroll the editor fully to the bottom once.
  • Continue typing → Now auto-scroll works properly.

Analysis

The issue seems to be caused by the initial content height not being reported correctly from the WebView.

The onCursorPosition / scrollHeight is only calculated after a full manual scroll, which forces a reflow.

Until that happens, the editor’s height is stuck, and the auto-scroll logic does not trigger correctly.

Possible Fix

Trigger a scrollHeight recalculation after editor mount:

window.onload = function () {
setTimeout(() => Actions.UPDATE_HEIGHT(), 300);
};
editor.content.addEventListener("input", () => {
Actions.UPDATE_HEIGHT();
});

Improve Actions.UPDATE_HEIGHT() to calculate using Math.max(body.scrollHeight, docEle.scrollHeight, editor.content.scrollHeight) instead of relying on a single value.

Ensure OFFSET_HEIGHT is sent to React Native before the first manual scroll.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions