fix for unfocusing bug

This commit is contained in:
Deven Joshi
2021-11-15 17:00:00 +05:30
parent a3cce7ffff
commit d923b01df7
2 changed files with 10 additions and 3 deletions
@@ -204,6 +204,7 @@ class MessageInput extends StatefulWidget {
this.commandButtonBuilder,
this.customOverlays = const [],
this.mentionAllAppUsers = false,
this.shouldKeepFocusAfterMessage,
}) : assert(
initialMessage == null || editMessage == null,
"Can't provide both `initialMessage` and `editMessage`",
@@ -322,6 +323,8 @@ class MessageInput extends StatefulWidget {
/// Defaults to false.
final bool mentionAllAppUsers;
final bool? shouldKeepFocusAfterMessage;
@override
MessageInputState createState() => MessageInputState();
@@ -1759,7 +1762,9 @@ class MessageInputState extends State<MessageInput> {
return;
}
final shouldUnfocus = _commandEnabled;
var shouldKeepFocus = widget.shouldKeepFocusAfterMessage;
shouldKeepFocus ??= !_commandEnabled;
if (_commandEnabled) {
text = '${'/${_chosenCommand!.name} '}$text';
@@ -1822,8 +1827,10 @@ class MessageInputState extends State<MessageInput> {
sendingFuture = channel.updateMessage(message);
}
if (!shouldUnfocus) {
if (shouldKeepFocus) {
FocusScope.of(context).requestFocus(_focusNode);
} else {
FocusScope.of(context).unfocus();
}
final resp = await sendingFuture;
@@ -444,7 +444,7 @@ class _MessageListViewState extends State<MessageListView> {
message: statusString,
child: LazyLoadScrollView(
onPageScrollStart: () {
FocusScope.of(context).unfocus();
//FocusScope.of(context).unfocus();
},
onStartOfPage: () async {
_inBetweenList = false;