From 820a88418cdb6f5249b5ded20dcec4b4780cd07f Mon Sep 17 00:00:00 2001 From: "Deepanshu.shukla" Date: Fri, 5 Jul 2024 15:38:00 -0700 Subject: [PATCH] fix: get all bytes from the text in native event key in fabric (#45274) Summary: Fixes https://github.com/facebook/react-native/issues/45199. Problem was whenever you type in TextInput **onKeypress** callback called and event key was returned as **keyPressMetrics.text.front();** which basically fetch the first byte from text . But in case of non-ascii character text is coming like ' \804'(in octal) which means first byte was empty string . So solution was the return whole text as it is i.e. **keyPressMetrics.text** ## Changelog: [IOS][FIXED] - nativeEvent key returning empty in case any non-ascii character entered , in IOS fabric For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/45274 Test Plan: Below are the screenrecording for solution in new arch https://github.com/facebook/react-native/assets/111736628/ea9034d3-3105-44e2-9998-4264d218ab93 Reviewed By: NickGerleman Differential Revision: D59405313 Pulled By: arushikesarwani94 fbshipit-source-id: 65e153b933f345e3ec66a691aa8a4ab15d651440 --- .../renderer/components/iostextinput/TextInputEventEmitter.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/TextInputEventEmitter.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp index c2262b03267..6eb58c1681a 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp @@ -118,7 +118,7 @@ static jsi::Value keyPressMetricsPayload( } else if (keyPressMetrics.text.front() == '\t') { key = "Tab"; } else { - key = keyPressMetrics.text.front(); + key = keyPressMetrics.text; } } payload.setProperty(