Skip to content

Feature request: onCaretRectChange callback for outer ScrollView coordination #233

@nick87kelly

Description

@nick87kelly

Is your feature request related to a problem? Please describe.
I'm using EnrichedMarkdownInput with scrollEnabled={false} inside a composer screen where the input is one of several elements (title, forum selector, media previews, poll builder) inside an outer ScrollView + KeyboardAvoidingView.

The problem: as the user types and the caret moves down (or they tap to reposition it), I need to scroll the outer ScrollView to keep the caret visible above the keyboard. Currently onChangeSelection only provides character offsets { start, end }, which isn't enough to determine the caret's pixel position — especially with word-wrapped lines.

Describe the solution you'd like
The native text systems already know the caret rect internally (iOS's UITextView can resolve a text position to a CGRect, Android's Layout has getLineForOffset/getLineTop/getPrimaryHorizontal). Would it be possible to surface this as a callback?

Something like:

onCaretRectChange?: (rect: {
  x: number;      // relative to input left
  y: number;      // relative to input top
  width: number;
  height: number;
}) => void;

This would fire whenever the caret moves (typing, selection change, content reflow). With this, the outer scroll container can compare the caret's position against the visible window and scroll the minimum amount needed — only when the caret actually leaves the visible area.

Use case: A post composer screen (similar to Twitter/Reddit) where EnrichedMarkdownInput is embedded in a larger scrollable form. The input grows with content (scrollEnabled={false}), and the parent ScrollView needs to keep the caret visible as the user types, taps to reposition, or the keyboard appears/disappears.

Describe alternatives you've considered
Without caret geometry from the native side, the only JS-side options are approximations (counting newlines × line height) which break down with word-wrapped lines.

Additional context
Maybe a solution to my problem currently exists, its something I've always struggled to solve even with regular TextInputs

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