Skip to content

Conversation

DanielCardonaRojas
Copy link

🔗 Issue Links

  • Fixes [#ISSUE_ID] (replace with Linear or GitHub issue link if available)

🎯 Goal

Ensure the chat composer TextField is reliably cleared after sending a message, when autocorrection is active and a SwiftUI TextField is used.

For context, my usecase requires me to use a custom configured TextField instead of ComposerInputView (UIViewRepresentable implementation) provided by this SDK. There is a race condition caused by clearing the text twice and the system autocorrection.


📝 Summary

  • Removed immediate text = "" call from clearInputData()
  • Kept deferred clear in clearText() to reset input after UIKit finishes applying autocorrections
  • Prevented a race condition between app state updates and UIKit’s delayed autocorrect commit

🛠 Implementation

  • Clearing text immediately conflicted with this delayed commit, causing the autocorrected text to reappear in the input field.
  • The fix removes the redundant immediate clear and relies solely on the deferred clear (DispatchQueue.main.asyncAfter).
  • This ensures the field is reset only after UIKit has finished its autocorrection cycle.

🎨 Showcase

Before After
Input sometimes still shows autocorrected text after sending Input reliably clears after sending

🧪 Manual Testing Notes

  1. Type a word that triggers autocorrection (e.g., tehthe).
  2. Without manually accepting the suggestion, tap Send.
  3. ✅ The message is sent and the input clears immediately.
  4. Repeat with different autocorrections and verify consistent behavior.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

@DanielCardonaRojas DanielCardonaRojas requested a review from a team as a code owner September 14, 2025 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants