Fixed double `onChange` event triggering from <TextInput> on iOS
Summary: The problem was recently introduced in the last refactoring of the Text module. There are two problem actually: (1) Compare this current code with stable version. In the stable version the event is only triggered here: https://github.com/facebook/react-native/blob/0.52-stable/Libraries/Text/RCTTextField.m#L132-L140 In the new version the event is triggered in two places (which is obviously wrong). (2) Executing `[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange:...]` and _onChange() actually do the same thing. Historically, the single-line <TextInput> used the first approach and multi-line used second one. When we unify the logic, mixed both of them, which was apparenly wrong. So, we have to remove another call of `[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange:...]`. The the future we have to completly remove usage of `_eventDispatcher` from this component. Depends on D6854770. Reviewed By: fkgozali Differential Revision: D6869678 fbshipit-source-id: 6705ee8dda2681ae184ef6716238cc8b62efeff1
This commit is contained in:
parent
7492860ffb
commit
d7fa81f181
|
@ -286,12 +286,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange
|
|
||||||
reactTag:self.reactTag
|
|
||||||
text:backedTextInputView.attributedText.string
|
|
||||||
key:nil
|
|
||||||
eventCount:_nativeEventCount];
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,12 +318,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
||||||
@"eventCount": @(_nativeEventCount),
|
@"eventCount": @(_nativeEventCount),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange
|
|
||||||
reactTag:self.reactTag
|
|
||||||
text:backedTextInputView.attributedText.string
|
|
||||||
key:nil
|
|
||||||
eventCount:_nativeEventCount];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)textInputDidChangeSelection
|
- (void)textInputDidChangeSelection
|
||||||
|
|
Loading…
Reference in New Issue