Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2802,7 +2802,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: ebcf3a78dc1bcdf054c9e8d309244bade6b31568
ReactCodegen: 11c08ff43a62009d48c71de000352e4515918801
ReactCommon: 424cc34cf5055d69a3dcf02f3436481afb8b0f6f
ReactNativeTypeRich: cb5b8ad8846095f5dea1a60e4d2050e04707487b
ReactNativeTypeRich: c684424c52f7529f439589a60d106ecaba3ea7d0
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 6ca93c8c13f56baeec55eb608577619b17a4d64e

Expand Down
2 changes: 2 additions & 0 deletions ios/TypeRichTextInputView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface TypeRichTextInputView : RCTViewComponentView <UITextViewDelegate>

@property(nonatomic, assign) BOOL blockEmitting;
@property (atomic, assign) BOOL isUserTyping;
@property (atomic, assign) CFTimeInterval lastTypingTime;

- (CGSize)measureSize:(CGFloat)maxWidth;

Expand Down
5 changes: 5 additions & 0 deletions ios/TypeRichTextInputView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#pragma mark - Implementation

@implementation TypeRichTextInputView {

Check warning on line 35 in ios/TypeRichTextInputView.mm

View workflow job for this annotation

GitHub Actions / build-ios

class 'TypeRichTextInputView' does not conform to protocol 'RCTTypeRichTextInputViewViewProtocol' [-Wprotocol]

Check warning on line 35 in ios/TypeRichTextInputView.mm

View workflow job for this annotation

GitHub Actions / build-ios

class 'TypeRichTextInputView' does not conform to protocol 'RCTTypeRichTextInputViewViewProtocol' [-Wprotocol]
/// Native text input
UITextView *_textView;

Expand Down Expand Up @@ -447,7 +447,7 @@
}

// Apply to existing text
NSMutableAttributedString *attributedText =

Check warning on line 450 in ios/TypeRichTextInputView.mm

View workflow job for this annotation

GitHub Actions / build-ios

unused variable 'attributedText' [-Wunused-variable]

Check warning on line 450 in ios/TypeRichTextInputView.mm

View workflow job for this annotation

GitHub Actions / build-ios

unused variable 'attributedText' [-Wunused-variable]
[[NSMutableAttributedString alloc]
initWithString:_textView.text ?: @""
attributes:attributes];
Expand Down Expand Up @@ -604,6 +604,9 @@
if (self.blockEmitting) return;
// _isHandlingUserInput = YES;

self.isUserTyping = YES;
self.lastTypingTime = CACurrentMediaTime();

[self updatePlaceholderVisibility];

// Emit JS onChangeText
Expand Down Expand Up @@ -647,6 +650,8 @@
- (void)textViewDidChangeSelection:(UITextView *)textView {
if (self.blockEmitting) return;

self.isUserTyping = NO;

auto emitter = [self getEventEmitter];
if (!emitter) {
return;
Expand Down
2 changes: 2 additions & 0 deletions ios/modules/commands/TypeRichTextInputCommands.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading