From c671e3df6631365443fc30694102b00f60d1113e Mon Sep 17 00:00:00 2001 From: jack <212554440+jackjackbits@users.noreply.github.com> Date: Sun, 26 Jul 2026 21:19:12 +0200 Subject: [PATCH] Keep the composer focused after sending with the return key (#1490) * Keep the composer focused after sending with the return key On iOS, return sends and then drops the keyboard, so every message in a back-and-forth costs an extra tap to reopen it. sendMessage() is the onSubmit handler; reasserting the FocusState there keeps the keyboard up between messages. macOS already refocuses on appear and is unaffected. Fixes #457 Co-Authored-By: Claude Fable 5 * Address Codex review: refocus only on return-key submission The reassert moves from sendMessage() into the TextField's onSubmit, so the send button no longer reopens a deliberately dismissed keyboard on iOS and never moves focus on macOS. Co-Authored-By: Claude Fable 5 --------- Co-authored-by: jack Co-authored-by: Claude Fable 5 --- bitchat/Views/ContentComposerView.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bitchat/Views/ContentComposerView.swift b/bitchat/Views/ContentComposerView.swift index 9913ce03..b5020980 100644 --- a/bitchat/Views/ContentComposerView.swift +++ b/bitchat/Views/ContentComposerView.swift @@ -73,7 +73,14 @@ struct ContentComposerView: View { .textInputAutocapitalization(.sentences) #endif .submitLabel(.send) - .onSubmit(onSendMessage) + .onSubmit { + onSendMessage() + // Only the return-key path: it steals focus on iOS, so + // every message would cost a tap to reopen the keyboard. + // The send button must not reopen a deliberately + // dismissed keyboard, so it stays out of this. + isTextFieldFocused.wrappedValue = true + } .padding(.vertical, theme.usesGlassChrome ? 8 : 4) .padding(.horizontal, 6) .themedInputBackground()