@@ -541,13 +541,9 @@ void WindowsTextInputComponentView::HandleCommand(
541541 std::optional<winrt::hstring> text;
542542
543543 winrt::Microsoft::ReactNative::ReadArgs (args.CommandArgs (), eventCount, text, begin, end);
544- // Accept text updates that match current event count, or clear text operations
545- // that are one event behind (to handle immediate setValue('') during onSubmitEditing)
546- bool isEmptyTextUpdate = text.has_value () && text.value ().empty ();
547- bool isValidEventCount = eventCount >= m_nativeEventCount;
548- bool isRecentClearText = isEmptyTextUpdate && (eventCount >= m_nativeEventCount - 1 );
549-
550- if (isValidEventCount || isRecentClearText) {
544+ // Only accept text updates that match the current native event count
545+ // This prevents race conditions and maintains proper state synchronization
546+ if (eventCount >= m_nativeEventCount) {
551547 m_comingFromJS = true ;
552548 {
553549 if (text.has_value ()) {
@@ -960,8 +956,12 @@ void WindowsTextInputComponentView::OnCharacterReceived(
960956 auto emitter = std::static_pointer_cast<const facebook::react::WindowsTextInputEventEmitter>(m_eventEmitter);
961957 facebook::react::WindowsTextInputEventEmitter::OnSubmitEditing onSubmitEditingArgs;
962958 onSubmitEditingArgs.text = GetTextFromRichEdit ();
963- onSubmitEditingArgs.eventCount = ++m_nativeEventCount;
959+ // Don't increment event count yet - let JS respond with current count first
960+ onSubmitEditingArgs.eventCount = m_nativeEventCount;
964961 emitter->onSubmitEditing (onSubmitEditingArgs);
962+
963+ // Increment after emitting to allow JS to respond with matching count
964+ ++m_nativeEventCount;
965965 }
966966
967967 if (m_clearTextOnSubmit) {
0 commit comments