diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4de9739..920a10b 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2449,7 +2449,7 @@ PODS: - React-perflogger (= 0.83.0) - React-utils (= 0.83.0) - SocketRocket - - ReactNativeTypeRich (2.1.0): + - ReactNativeTypeRich (2.1.1): - boost - DoubleConversion - fast_float @@ -2802,7 +2802,7 @@ SPEC CHECKSUMS: ReactAppDependencyProvider: ebcf3a78dc1bcdf054c9e8d309244bade6b31568 ReactCodegen: 11c08ff43a62009d48c71de000352e4515918801 ReactCommon: 424cc34cf5055d69a3dcf02f3436481afb8b0f6f - ReactNativeTypeRich: cb5b8ad8846095f5dea1a60e4d2050e04707487b + ReactNativeTypeRich: c684424c52f7529f439589a60d106ecaba3ea7d0 SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 Yoga: 6ca93c8c13f56baeec55eb608577619b17a4d64e diff --git a/ios/TypeRichTextInputView.h b/ios/TypeRichTextInputView.h index 9d4ef40..94f0d2e 100644 --- a/ios/TypeRichTextInputView.h +++ b/ios/TypeRichTextInputView.h @@ -7,6 +7,8 @@ NS_ASSUME_NONNULL_BEGIN @interface TypeRichTextInputView : RCTViewComponentView @property(nonatomic, assign) BOOL blockEmitting; +@property (atomic, assign) BOOL isUserTyping; +@property (atomic, assign) CFTimeInterval lastTypingTime; - (CGSize)measureSize:(CGFloat)maxWidth; diff --git a/ios/TypeRichTextInputView.mm b/ios/TypeRichTextInputView.mm index d6c3d8d..5e7eb43 100644 --- a/ios/TypeRichTextInputView.mm +++ b/ios/TypeRichTextInputView.mm @@ -604,6 +604,9 @@ - (void)textViewDidChange:(UITextView *)textView { if (self.blockEmitting) return; // _isHandlingUserInput = YES; + self.isUserTyping = YES; + self.lastTypingTime = CACurrentMediaTime(); + [self updatePlaceholderVisibility]; // Emit JS onChangeText @@ -647,6 +650,8 @@ - (void)textViewDidEndEditing:(UITextView *)textView { - (void)textViewDidChangeSelection:(UITextView *)textView { if (self.blockEmitting) return; + self.isUserTyping = NO; + auto emitter = [self getEventEmitter]; if (!emitter) { return; diff --git a/ios/modules/commands/TypeRichTextInputCommands.mm b/ios/modules/commands/TypeRichTextInputCommands.mm index 028e080..ad469c1 100644 --- a/ios/modules/commands/TypeRichTextInputCommands.mm +++ b/ios/modules/commands/TypeRichTextInputCommands.mm @@ -67,6 +67,8 @@ - (void)setText:(NSString *)text dispatch_async(dispatch_get_main_queue(), ^{ if (tv.markedTextRange) return; + if (owner.isUserTyping) return; + NSString *newText = text ?: @""; owner.blockEmitting = YES;