Repository navigation
fix(Android): Measurement jumps - #864
Conversation
…ve-enriched-html into @relextm19/scroll-position
…ve-enriched-html into @relextm19/scroll-position
…ve-enriched-html into @relextm19/scroll-position
There was a problem hiding this comment.
🟡 Changes recommended
Android scroll-cap races and stale limits can cause visual jumps or prevent scrolling needed to keep the cursor visible, while iOS offset caching can suppress valid scroll events after a listener is reattached.
2 open issues
What changed in this PR
This PR addresses Android input measurement and scrolling jumps during auto-growth. It also adds cross-platform onScroll events, documentation, and example coverage.
Changes:
- Align Android measurements with locale-preferred line heights and cap scrolling while height updates are pending.
- Expose scroll offsets on Android, iOS, and web, and avoid scroll-triggered iOS relayouts.
- Add scroll-event tests and example instrumentation.
| File | Description |
|---|---|
src/web/EnrichedTextInput.tsx |
Forward web scroll offsets to the callback. |
src/types.ts |
Define public scroll event types and prop. |
src/spec/EnrichedTextInputNativeComponent.ts |
Declare native scroll events and emission flag. |
src/native/EnrichedTextInput.tsx |
Connect the public callback to native props. |
src/index.tsx |
Export the scroll payload type. |
src/index.native.tsx |
Export the native scroll payload type. |
ios/EnrichedTextInputView.mm |
Emit iOS scroll offset events. |
ios/enrichedInputTextView/EnrichedInputTextView.mm |
Limit relayout scheduling to size changes. |
docs/docs/api-reference/enriched-text-input.md |
Document onScroll and its payload. |
apps/example/src/screens/TestScreen.tsx |
Display settled scroll offsets for tests. |
apps/example/src/screens/DevScreen.tsx |
Log input scroll events. |
apps/example/src/hooks/useEditorState.ts |
Add a shared scroll logger. |
apps/example/src/components/ModalShell.tsx |
Use padding-based keyboard avoidance. |
apps/example/src/App.tsx |
Pass the scroll-display launch option. |
apps/example/ios/EnrichedTextInputExample/SceneDelegate.swift |
Forward the iOS test launch argument. |
apps/example/android/app/src/main/java/swmansion/enriched/example/MainActivity.kt |
Forward the Android test launch argument. |
apps/example-web/src/testScreens/TestScroll.tsx |
Add a scroll-event test screen. |
apps/example-web/src/RouteSelector.tsx |
Register the scroll test route. |
apps/example-web/src/App.tsx |
Log web scroll events. |
android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt |
Match line metrics and cache growth limits. |
android/src/main/java/com/swmansion/enriched/textinput/events/OnInputScrollEvent.kt |
Define the Android scroll event payload. |
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt |
Register scroll events and acknowledge state mounts. |
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewLayoutManager.kt |
Mark height recalculations as pending. |
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt |
Cap pending-resize scrolling and emit offsets. |
.playwright/tests/scroll.spec.ts |
Test web scroll events and offset direction. |
.maestro/enrichedInput/flows/on_scroll_event.yaml |
Test native scroll offset changes. |
.maestro/enrichedInput/flows/image_inside_list_parsing.yaml |
Use a repository-hosted test image. |
Review effort: Balanced
b654cda to
06d8dd9
Compare
|
How does it work in React Native TextInput? Visually, layout jumping is the same |
exploIF
left a comment
There was a problem hiding this comment.
We had many issues in the past if it comes to input layout. There are no recent errors reported, so I'm not sure if it really makes sense to introduce potential regressions. What are the pros of this changes?
|
In the description there is a note
Unfortunately, I don't see any such changes |
|
@exploIF About the note with test script cases; I moved it to a different, already merged PR and removed from this one - forgot to change the description here 🙏 |
RN TextInput has the same issue so we're essentially improving over it. Here's
The main motivation is the new If it comes to any potential regressions; all the Android E2E tests pass + I made a few manual sweeps + I made Argent go over the app and seek any abnormalities for quite some time - I'm pretty confident we're not risking much. About the benefits; except for the
I've just had Argent run pre- and post- fix apps built on APIs 34 and 36 and both work as expected - the tiny discrepancies in offsets are caused by changes the API35 brought when measuring lines:
|

Summary
While testing new
onScrollprop I found out that we've had issues with Android measurement jumps pretty much since auto-growth was added.It can be seen here:
Screen.Recording.2026-11-12.at.18.28.38.mov
Basically, strange scrolls and Input component offsets whenever:
maxHeight1. Empty lines measured too short
For apps targeting SDK 35+,
EditTextuses a locale-preferred minimum line height (setLocalePreferredLineHeightForMinimumUsed), which keeps empty lines as tall as lines with text.MeasurementStore'sStaticLayoutdidn't apply it, so empty and code block lines were measured a few px shorter than drawn. The view came out too short andEditTextscrolled by the difference (the0.76offset).Fix:
MeasurementStoreapplies the samesetMinimumFontMetrics(paint.getFontMetricsForLocale(...))when the view uses it.2. One-line jump while growing
The height update goes through an async Fabric state update. Before the view grows, the new line is already laid out, and
EditTextscrolls it into view, then back after the resize (0 → 24.76 → 0).Fix: while a height update is pending,
scrollTocaps the scroll at the value it will have after the resize. It works that out from the height limit Yoga passes tomeasure():0if the text fits under it, or the final offset if the text crosses it. Once the input is atmaxHeight, behaviour is unchanged.Test Plan
On Android 15+ (tested on Pixel 9, API 36), with an input that has
maxHeightand logsonScroll:maxHeight: no scroll eventsmaxHeight: one event with the final offsetAndroid screenshot baselines were updated too for affected tests.
Screenshots / Videos
You can see offsets are now properly returned. The only edge case is the first returned offset when we exceed the
maxHeightcontent height, but it just double-emits two very similar values which (according to Claude) is expected and not a big deal. It's not like0->24->0jump, which was happening before.Screen.Recording.2026-11-13.at.15.21.50.mov
Compatibility
Checklist