@@ -36,6 +36,9 @@ @implementation RCTBaseTextInputView {
36
36
BOOL _hasInputAccessoryView;
37
37
// [macOS] remove explicit _predictedText ivar declaration
38
38
BOOL _didMoveToWindow;
39
+ #if TARGET_OS_OSX // [macOS avoids duplicating effects of textInputDid(Begin|End)Editing calls
40
+ BOOL _isCurrentlyEditing;
41
+ #endif // macOS]
39
42
}
40
43
41
44
#if !TARGET_OS_OSX // [macOS]
@@ -71,6 +74,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
71
74
if (self = [super initWithEventDispatcher: bridge.eventDispatcher]) { // [macOS]
72
75
_bridge = bridge;
73
76
_eventDispatcher = bridge.eventDispatcher ;
77
+ #if TARGET_OS_OSX // [macOS
78
+ _isCurrentlyEditing = NO ;
79
+ #endif // macOS]
74
80
}
75
81
76
82
return self;
@@ -446,6 +452,13 @@ - (BOOL)textInputShouldBeginEditing
446
452
447
453
- (void )textInputDidBeginEditing
448
454
{
455
+ #if TARGET_OS_OSX // [macOS consolidate duplicate callbacks
456
+ if (_isCurrentlyEditing) {
457
+ return ;
458
+ }
459
+ _isCurrentlyEditing = YES ;
460
+ #endif // macOS]
461
+
449
462
if (_clearTextOnFocus) {
450
463
self.backedTextInputView .attributedText = [NSAttributedString new ];
451
464
}
@@ -474,6 +487,13 @@ - (BOOL)textInputShouldEndEditing
474
487
475
488
- (void )textInputDidEndEditing
476
489
{
490
+ #if TARGET_OS_OSX // [macOS consolidate duplicate callbacks
491
+ if (!_isCurrentlyEditing) {
492
+ return ;
493
+ }
494
+ _isCurrentlyEditing = NO ;
495
+ #endif // macOS]
496
+
477
497
self.ghostText = nil ; // [macOS]
478
498
479
499
[_eventDispatcher sendTextEventWithType: RCTTextEventTypeEnd
0 commit comments