fix(ui): overflow of mentions overlay & input focus node

This commit is contained in:
geweald
2022-03-02 13:31:41 +01:00
parent d1f7c1fd14
commit 3583b79789
2 changed files with 37 additions and 23 deletions
@@ -1,3 +1,9 @@
## Upcoming
🐞 Fixed
- Mentions overlay now doesn't overflow when not enough height available
## 3.5.0
🐞 Fixed
@@ -344,6 +344,7 @@ class MessageInputState extends State<MessageInput> {
final _imagePicker = ImagePicker();
late final _focusNode = widget.focusNode ?? FocusNode();
late final _isInternalFocusNode = widget.focusNode == null;
bool _inputEnabled = true;
bool _commandEnabled = false;
bool _showCommandsOverlay = false;
@@ -1191,30 +1192,36 @@ class MessageInputState extends State<MessageInput> {
};
}
return UserMentionsOverlay(
query: query,
mentionAllAppUsers: widget.mentionAllAppUsers,
client: StreamChat.of(context).client,
channel: channel,
size: Size(renderObject.size.width - 16, 400),
mentionsTileBuilder: tileBuilder,
onMentionUserTap: (user) {
_mentionedUsers.add(user);
splits[splits.length - 1] = user.name;
final rejoin = splits.join('@');
return LayoutBuilder(
builder: (context, snapshot) => UserMentionsOverlay(
query: query,
mentionAllAppUsers: widget.mentionAllAppUsers,
client: StreamChat.of(context).client,
channel: channel,
size: Size(
renderObject.size.width - 16,
min(400, (snapshot.maxHeight - renderObject.size.height - 16).abs()),
),
mentionsTileBuilder: tileBuilder,
onMentionUserTap: (user) {
_mentionedUsers.add(user);
splits[splits.length - 1] = user.name;
final rejoin = splits.join('@');
textEditingController.value = TextEditingValue(
text: rejoin +
textEditingController.text.substring(
textEditingController.selection.start,
),
selection: TextSelection.collapsed(
offset: rejoin.length,
),
);
_onChangedDebounced.cancel();
setState(() => _showMentionsOverlay = false);
},
textEditingController.value = TextEditingValue(
text: rejoin +
textEditingController.text.substring(
textEditingController.selection.start,
),
selection: TextSelection.collapsed(
offset: rejoin.length,
),
);
_onChangedDebounced.cancel();
setState(() => _showMentionsOverlay = false);
},
),
);
}
@@ -1925,6 +1932,7 @@ class MessageInputState extends State<MessageInput> {
void dispose() {
textEditingController.dispose();
_focusNode.removeListener(_focusNodeListener);
if (_isInternalFocusNode) _focusNode.dispose();
_stopSlowMode();
_onChangedDebounced.cancel();
super.dispose();