mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix event emits during initial rendering in Fabric (#42777)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42777 During view preallocation eventEmitter information is not being passed to the platform. This causes bugs with emision of events during initial rendering when using the new Fabric Event dispatching system. e.g. Rendering a TextInput that has 'onFocus' event and also has autoFocus enabled. The new Fabric Event dispatching system dispatch events earlier (this is expected) In this diff I'm fixing this issue by ensuring that all preallocated views have an eventEmitter (when its shadowNode has an eventEmitter) This was actually implemented in the past, but in order to optimize, we run an experiment (D29117957) and it was later deleted. (D40356386). I didn't find details of the results of the experiment. We could run another experiment to understand potential negative perf impact of this change, although I believe it's the right thing to do here. Changelog: [Android][Fixed] Fix delivery of events during initial rendering in new architecture Reviewed By: sammy-SC Differential Revision: D53108114 fbshipit-source-id: 0b56b7495db63e4a478f4b34e91f4bcbf452ef92
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1170a68755
commit
7b36233ae1
+1
@@ -177,6 +177,7 @@ public class TextAttributes {
|
||||
: DEFAULT_MAX_FONT_SIZE_MULTIPLIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("TextAttributes {"
|
||||
+ "\n getAllowFontScaling(): "
|
||||
|
||||
@@ -810,6 +810,11 @@ void FabricMountingManager::preallocateShadowView(
|
||||
|
||||
// Do not hold a reference to javaEventEmitter from the C++ side.
|
||||
jni::local_ref<EventEmitterWrapper::JavaPart> javaEventEmitter = nullptr;
|
||||
SharedEventEmitter eventEmitter = shadowView.eventEmitter;
|
||||
if (eventEmitter != nullptr) {
|
||||
javaEventEmitter =
|
||||
EventEmitterWrapper::newObjectCxxArgs(shadowView.eventEmitter);
|
||||
}
|
||||
|
||||
jni::local_ref<jobject> props = getProps({}, shadowView);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user