From a26baae65c8478522676b1b87e79297eb0738f89 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 28 Oct 2024 18:16:09 -0700 Subject: [PATCH] Fix missing event emitters on iOS TextInput when controlled component value specified using `value` instead of `children` Summary: There were [reports](https://github.com/reactwg/react-native-releases/issues/595) that patching in the fixes for iOS controlled input did not work as expected. I think tracked this down to a difference in how I tested, where the controlled component I used passed value as a child of the `TextInput`, instead of via `value`. Passing via `value` triggers a secondary bug, where we don't correctly pass a reference to correct ShadowView when creating attributedstring, specifically in the iOS TextInputShadowNode impl. This was first exposed in D52589303 which enabled `-Wextra`, but there, we went with same behavior of passing empty ShadowView, instead of the correct behavior (like Android impl) of passing a ShadowView of the current ShadowNode. After fixing this, we now correctly create event emitters in the passed attributedstring, which matches expectations for pargraph-level eventemitter now in typing attributes. We don't seem actually use this on iOS for TextInput right now (just Text), but this is likely the right foundation for events regardless. Changelog: [iOS][Fixed] - Fix missing event emitters on iOS TextInput when controlled component value specified using `value` instead of `children` Differential Revision: D65108163 --- .../renderer/components/iostextinput/TextInputShadowNode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputShadowNode.cpp index b0a58614ac8725..770dd82df5e2f6 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputShadowNode.cpp @@ -83,7 +83,7 @@ AttributedString TextInputShadowNode::getAttributedString( .string = getConcreteProps().text, .textAttributes = textAttributes, // TODO: Is this really meant to be by value? - .parentShadowView = ShadowView{}}); + .parentShadowView = ShadowView(*this)}); auto attachments = Attachments{}; BaseTextShadowNode::buildAttributedString(