Skip to content

Commit fbe38bb

Browse files
NickGerlemanblakef
authored andcommitted
Fix missing emitter attributes on iOS TextInput when controlled component value specified using value instead of children (#47269)
Summary: Pull Request resolved: #47269 There were [reports](reactwg/react-native-releases#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. We previously passed nothing for the ShadowView (only the first two struct fields). This was exposed in D52589303 which enabled `-Wextra`, but there, I 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 emitter attributes on iOS TextInput when controlled component value specified using `value` instead of `children` Reviewed By: cipolleschi Differential Revision: D65108163 fbshipit-source-id: 499fe28439fabd2579eca6ded7fd13fd8ea2e43e
1 parent 40093d9 commit fbe38bb

File tree

1 file changed

+3
-2
lines changed
  • packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput

1 file changed

+3
-2
lines changed

packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputShadowNode.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ AttributedString TextInputShadowNode::getAttributedString(
8383
.string = getConcreteProps().text,
8484
.textAttributes = textAttributes,
8585
// TODO: Is this really meant to be by value?
86-
.parentShadowView = ShadowView{}});
86+
.parentShadowView = ShadowView(*this)});
8787

8888
auto attachments = Attachments{};
8989
BaseTextShadowNode::buildAttributedString(
@@ -110,7 +110,8 @@ void TextInputShadowNode::updateStateIfNeeded(
110110
(!state.layoutManager || state.layoutManager == textLayoutManager_) &&
111111
"`StateData` refers to a different `TextLayoutManager`");
112112

113-
if (state.reactTreeAttributedString == reactTreeAttributedString &&
113+
if (state.reactTreeAttributedString.isContentEqual(
114+
reactTreeAttributedString) &&
114115
state.layoutManager == textLayoutManager_) {
115116
return;
116117
}

0 commit comments

Comments
 (0)