Skip to content

Commit

Permalink
Fix: multiline textinput start "jerking" when trying to move cursor. (#…
Browse files Browse the repository at this point in the history
…32179)

Summary:
Fixes #30748: on iOS 14, when trying to hold down the space bar and move the cursor on a multi-line TextInput with lots of lines, the cursor could not be scrolled to the desired point. It works as expected on iOS 13 and before.

Figured out that iOS14 acting as expected without `[setContentOffset:animated:]`, so exclude it when iOS version is and above 14.

Credit to efstathiosntonas for the finding and solution provides.

## Related issue
- #30748

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fixed the issue when moving cursor in multi-line TextInput.

Pull Request resolved: #32179

Test Plan:
1. Launch RNTester app on iOS
2. Open `TextInput` in tab `Components`
3. Scroll to `Multiline` section and focus on the first child
4. Input lots of dummy texts
5. Hold the space bar (on device) or press down the mouse inside `TextInput` (simulator without showing keyboard)

### **Video Before:**
https://user-images.githubusercontent.com/6382178/132800651-fb7cd2ac-fbd1-4ec4-9e3b-c06ab5b6a114.MP4

### **Video After:**
https://user-images.githubusercontent.com/6382178/132800677-f349fe7f-5902-40ff-8b93-ecc96ce29166.MP4

Reviewed By: philIip

Differential Revision: D31404248

Pulled By: lunaleaps

fbshipit-source-id: 74a39106e628602c5177fc243783288fcb7782fa
  • Loading branch information
xiankuncheng authored and facebook-github-bot committed Oct 6, 2021
1 parent 3562364 commit 2280187
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Libraries/Text/TextInput/Multiline/RCTUITextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,14 @@ - (void)paste:(id)sender
_textWasPasted = YES;
}

// Turn off scroll animation to fix flaky scrolling.
// This is only necessary for iOS <= 13.
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < 140000
- (void)setContentOffset:(CGPoint)contentOffset animated:(__unused BOOL)animated
{
// Turning off scroll animation.
// This fixes the problem also known as "flaky scrolling".
[super setContentOffset:contentOffset animated:NO];
}
#endif

- (void)selectAll:(id)sender
{
Expand Down

0 comments on commit 2280187

Please sign in to comment.