fix: return focus to message input after sending

Added FocusNode to TextField, requestFocus() after send completes.
Also autofocus=true so cursor is in the input when entering a room.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 16:18:39 +10:00
parent c56c2d59fd
commit 5a6d6cadaf

View File

@@ -52,6 +52,7 @@ class MessageInput extends StatefulWidget {
class _MessageInputState extends State<MessageInput> {
final _controller = TextEditingController();
final _focusNode = FocusNode();
bool _hasText = false;
bool _isPickingFile = false;
@@ -67,6 +68,7 @@ class _MessageInputState extends State<MessageInput> {
@override
void dispose() {
_controller.dispose();
_focusNode.dispose();
super.dispose();
}
@@ -75,6 +77,8 @@ class _MessageInputState extends State<MessageInput> {
if (text.isEmpty) return;
_controller.clear();
await widget.onSend(text);
// Return focus to the input so the user can keep typing.
_focusNode.requestFocus();
}
Future<void> _pickFile() async {
@@ -180,6 +184,8 @@ class _MessageInputState extends State<MessageInput> {
Expanded(
child: TextField(
controller: _controller,
focusNode: _focusNode,
autofocus: true,
decoration: const InputDecoration(
hintText: 'Message',
contentPadding: EdgeInsets.symmetric(