Skip to content

Commit 2280187

Browse files
xiankunchengfacebook-github-bot
authored andcommitted
Fix: multiline textinput start "jerking" when trying to move cursor. (#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
1 parent 3562364 commit 2280187

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Libraries/Text/TextInput/Multiline/RCTUITextView.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,14 @@ - (void)paste:(id)sender
182182
_textWasPasted = YES;
183183
}
184184

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

192194
- (void)selectAll:(id)sender
193195
{

0 commit comments

Comments
 (0)