@@ -541,9 +541,12 @@ void WindowsTextInputComponentView::HandleCommand(
541541 std::optional<winrt::hstring> text;
542542
543543 winrt::Microsoft::ReactNative::ReadArgs (args.CommandArgs (), eventCount, text, begin, end);
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) {
544+ // Accept text updates that match current event count, or are within a reasonable
545+ // tolerance for async JS responses to recent events (like onSubmitEditing)
546+ bool isCurrentEvent = eventCount >= m_nativeEventCount;
547+ bool isRecentAsyncResponse = (m_nativeEventCount - eventCount) <= 2 ; // Allow up to 2 events behind
548+
549+ if (isCurrentEvent || isRecentAsyncResponse) {
547550 m_comingFromJS = true ;
548551 {
549552 if (text.has_value ()) {
@@ -956,12 +959,8 @@ void WindowsTextInputComponentView::OnCharacterReceived(
956959 auto emitter = std::static_pointer_cast<const facebook::react::WindowsTextInputEventEmitter>(m_eventEmitter);
957960 facebook::react::WindowsTextInputEventEmitter::OnSubmitEditing onSubmitEditingArgs;
958961 onSubmitEditingArgs.text = GetTextFromRichEdit ();
959- // Don't increment event count yet - let JS respond with current count first
960- onSubmitEditingArgs.eventCount = m_nativeEventCount;
962+ onSubmitEditingArgs.eventCount = ++m_nativeEventCount;
961963 emitter->onSubmitEditing (onSubmitEditingArgs);
962-
963- // Increment after emitting to allow JS to respond with matching count
964- ++m_nativeEventCount;
965964 }
966965
967966 if (m_clearTextOnSubmit) {
0 commit comments