Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: Show mention OverlayEntry to relative to Overlay #109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/src/widgets/input_toolbar/input_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,18 @@ class InputToolbarState extends State<InputToolbar>

void _showMentionModal(List<Widget> children) {
final OverlayState overlay = Overlay.of(context);
final RenderBox renderBox = context.findRenderObject() as RenderBox;
final Offset topLeftCornerOffset = renderBox.localToGlobal(Offset.zero);
final RenderBox overlayRenderBox =
overlay.context.findRenderObject() as RenderBox;
final RenderBox toolbarRenderBox = context.findRenderObject() as RenderBox;

double bottomPosition =
MediaQuery.of(context).size.height - topLeftCornerOffset.dy;
final double toolbarOffsetY =
toolbarRenderBox.localToGlobal(Offset.zero).dy;
final double overlayOffsetY =
overlayRenderBox.localToGlobal(Offset.zero).dy;

final double toolbarTopOffset = toolbarOffsetY - overlayOffsetY;

double bottomPosition = overlayRenderBox.size.height - toolbarTopOffset;
if (widget.inputOptions.inputToolbarMargin != null) {
bottomPosition -= widget.inputOptions.inputToolbarMargin!.top -
widget.inputOptions.inputToolbarMargin!.bottom;
Expand All @@ -190,7 +197,7 @@ class InputToolbarState extends State<InputToolbar>
_overlayEntry = OverlayEntry(
builder: (BuildContext context) {
return Positioned(
width: renderBox.size.width,
width: toolbarRenderBox.size.width,
bottom: bottomPosition,
child: Container(
constraints: BoxConstraints(
Expand Down