From 7e81c1d483e8590b9ff0392f76ee2f4b60bc82bb Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 4 Mar 2021 10:51:10 -0800 Subject: [PATCH] Implement caretHidden in multiline text input Summary: Changelog: [internal] Add missing implementation of caretHidden to multiline text input. This will work for both React Native Classic and New React Native Renderer. Reviewed By: shergin Differential Revision: D26818087 fbshipit-source-id: 3597604a6bd414a4a3b292d809d63a18efa8acb3 --- Libraries/Text/TextInput/Multiline/RCTUITextView.h | 2 -- Libraries/Text/TextInput/Multiline/RCTUITextView.m | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.h b/Libraries/Text/TextInput/Multiline/RCTUITextView.h index 8f4526bd404..5cb03eed62c 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.h +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.h @@ -33,8 +33,6 @@ NS_ASSUME_NONNULL_BEGIN // it's declared here only to conform to the interface. @property (nonatomic, assign) UITextFieldViewMode clearButtonMode; -// The `caretHidden` property actually is not supported yet; -// it's declared here only to conform to the interface. @property (nonatomic, assign) BOOL caretHidden; @property (nonatomic, strong, nullable) NSString *inputAccessoryViewID; diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 2d6f6eb43a3..2f72cb83fa5 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -165,8 +165,6 @@ static UIColor *defaultPlaceholderColor() [self textDidChange]; } -#pragma mark - Overrides - - (void)setSelectedTextRange:(UITextRange *)selectedTextRange notifyDelegate:(BOOL)notifyDelegate { if (!notifyDelegate) { @@ -298,6 +296,17 @@ static UIColor *defaultPlaceholderColor() return textAttributes; } +#pragma mark - Caret Manipulation + +- (CGRect)caretRectForPosition:(UITextPosition *)position +{ + if (_caretHidden) { + return CGRectZero; + } + + return [super caretRectForPosition:position]; +} + #pragma mark - Utility Methods - (void)copyTextAttributesFrom:(NSAttributedString *)sourceString