Skip to content

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented Oct 10, 2025

📜 Description

Fixed a problem with unexpected scroll in KeyboardAwareScrollView when you edit text in multiline input (which is bigger than screen size) in the beginning of the input.

💡 Motivation and Context

This PR enhances logic added in #491 When we deal with multiline inputs we may receive wrong selection coordinates. In #491 we were receiving them when input was growing (increasing its size). In this PR I discovered that we may receive a wrong selection coordinates even when input size remains the same.

Note

This bug is reproducible only on new architecture (I think it's a matter of timing and on new architecture everything is more synchronous comparing to old architecture).

So in this PR I'm enhancing functionality of canSelectionFitIntoLayout:

  • I return true if it's not multiline input;
  • I'm enforcing layout via textView.layoutManager.ensureLayout(for: textView.textContainer) to assure react calculation is correct

I thought to compare incorrect selection coordinates with input layout (I though that selection may be out-of-range so we can exclude this event), but turns out this wrong selection event is within size bounds: rect CGRect (origin = (x = 0, y = 1186.3333333333333), size = (width = 0, height = 53.666666666666664) (selection) vs size : (368.0, 1240.6666259765625) (layout).

I also checked and #489 is not reproducible

Closes #1148

📢 Changelog

iOS

  • return true from canSelectionFitIntoLayout if it's not multiline input;
  • call ensureLayout to read correct rect frame.

🤔 How Has This Been Tested?

Tested manually on iPhone 16 Pro (iOS 26, XCode 26).

📸 Screenshots (if appropriate):

Before After
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-10-11.at.12.50.39.mov
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-10-11.at.12.48.11.mov

📝 Checklist

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

@kirillzyusko kirillzyusko self-assigned this Oct 10, 2025
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🍎 iOS iOS specific 🏭 fabric Changes specific to new (fabric/jsi) architecture labels Oct 10, 2025
Copy link
Contributor

github-actions bot commented Oct 10, 2025

📊 Package size report

Current size Target Size Difference
223889 bytes 223822 bytes 67 bytes 📈

@kirillzyusko kirillzyusko merged commit 89fa05d into main Oct 12, 2025
18 of 19 checks passed
@kirillzyusko kirillzyusko deleted the fix/wrong-selection-coordinates-dispatch branch October 12, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working 🏭 fabric Changes specific to new (fabric/jsi) architecture 🍎 iOS iOS specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] KeyboardAwareScrollView still scrolls to end when current TextInput cursor is at top

2 participants