From 73bfb0e5b449f1f749a245c9640730280ce78cee Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Mon, 25 Sep 2023 09:22:54 +0200 Subject: [PATCH] fix: menu unable to be shown on repeated posts --- src/kaiteki/lib/ui/shared/posts/layouts/expanded.dart | 4 +++- src/kaiteki/lib/ui/shared/posts/layouts/normal.dart | 3 +++ src/kaiteki/lib/ui/shared/posts/layouts/wide.dart | 4 +++- src/kaiteki/lib/ui/shared/posts/post_widget.dart | 8 +++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/kaiteki/lib/ui/shared/posts/layouts/expanded.dart b/src/kaiteki/lib/ui/shared/posts/layouts/expanded.dart index 692e18571..7be8aefa0 100644 --- a/src/kaiteki/lib/ui/shared/posts/layouts/expanded.dart +++ b/src/kaiteki/lib/ui/shared/posts/layouts/expanded.dart @@ -57,9 +57,11 @@ class ExpandedPostLayout extends ConsumerWidget { ), ExpandedPostLayout( repeatOf, - onOpen: onOpen, callbacks: callbacks, onReact: onReact, + onOpen: onOpen, + onTap: onTap, + menuFocusNode: menuFocusNode, ), ], ); diff --git a/src/kaiteki/lib/ui/shared/posts/layouts/normal.dart b/src/kaiteki/lib/ui/shared/posts/layouts/normal.dart index 55eddd635..7269effaa 100644 --- a/src/kaiteki/lib/ui/shared/posts/layouts/normal.dart +++ b/src/kaiteki/lib/ui/shared/posts/layouts/normal.dart @@ -60,6 +60,9 @@ class NormalPostLayout extends ConsumerWidget { repeatOf, callbacks: callbacks, onReact: onReact, + onOpen: onOpen, + onTap: onTap, + menuFocusNode: menuFocusNode, ), ], ); diff --git a/src/kaiteki/lib/ui/shared/posts/layouts/wide.dart b/src/kaiteki/lib/ui/shared/posts/layouts/wide.dart index ba3090f51..deea59a90 100644 --- a/src/kaiteki/lib/ui/shared/posts/layouts/wide.dart +++ b/src/kaiteki/lib/ui/shared/posts/layouts/wide.dart @@ -54,9 +54,11 @@ class WidePostLayout extends ConsumerWidget { ), WidePostLayout( repeatOf, - onOpen: onOpen, callbacks: callbacks, onReact: onReact, + onOpen: onOpen, + onTap: onTap, + menuFocusNode: menuFocusNode, ), ], ); diff --git a/src/kaiteki/lib/ui/shared/posts/post_widget.dart b/src/kaiteki/lib/ui/shared/posts/post_widget.dart index f74c7fbf0..f0cc02031 100644 --- a/src/kaiteki/lib/ui/shared/posts/post_widget.dart +++ b/src/kaiteki/lib/ui/shared/posts/post_widget.dart @@ -214,10 +214,12 @@ class _PostWidgetState extends ConsumerState { final anchor = _menuAnchorKey.currentContext!.findRenderObject() as RenderBox; - final button = - _menuButtonFocusNode.context!.findRenderObject() as RenderBox; + final buttonContext = _menuButtonFocusNode.context; - final offset = button.localToGlobal(Offset.zero, ancestor: anchor); + assert(buttonContext != null); + + final buttonRenderBox = buttonContext!.findRenderObject() as RenderBox; + final offset = buttonRenderBox.localToGlobal(Offset.zero, ancestor: anchor); _menuController.open(position: offset); }