From 9906ef57ea52969a1fd9c6cc85d972ba7c5641f6 Mon Sep 17 00:00:00 2001 From: E-m-i-n-e-n-c-e Date: Fri, 21 Feb 2025 20:11:21 +0530 Subject: [PATCH] combined feed: Fix channel header tap behaviour in combined feed Set gesture detecter behavior of streamWidget to HitTestBehavior.opaque to handle taps in empty space around the header. Also added a test that checks if tapping empty space in channel header area correctly navigates to the channel feed. Fixes #1179. --- lib/widgets/message_list.dart | 1 + test/widgets/message_list_test.dart | 34 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 127bd65c61..927b016f60 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -1083,6 +1083,7 @@ class StreamMessageRecipientHeader extends StatelessWidget { ?? zulipLocalizations.unknownChannelName; // TODO(log) streamWidget = GestureDetector( + behavior: HitTestBehavior.opaque, onTap: () => Navigator.push(context, MessageListPage.buildRoute(context: context, narrow: ChannelNarrow(message.streamId))), diff --git a/test/widgets/message_list_test.dart b/test/widgets/message_list_test.dart index b7384824fd..4214f59d4a 100644 --- a/test/widgets/message_list_test.dart +++ b/test/widgets/message_list_test.dart @@ -1470,4 +1470,38 @@ void main() { ..status.equals(AnimationStatus.dismissed); }); }); + + testWidgets("navigates to ChannelNarrow when tapping the empty space in the channel part area of the CombinedFeedNarrow header", (tester) async { + final pushedRoutes = >[]; + final navObserver = TestNavigatorObserver() + ..onPushed = (route, prevRoute) => pushedRoutes.add(route); + final channel = eg.stream(); + final message = eg.streamMessage(stream: channel); + await setupMessageListPage(tester, + narrow: const CombinedFeedNarrow(), + streams: [channel], + subscriptions: [eg.subscription(channel)], + messages: [message], + navObservers: [navObserver]); + + assert(pushedRoutes.length == 1); + pushedRoutes.clear(); + + connection.prepare(json: eg.newestGetMessagesResult( + foundOldest: true, messages: [message]).toJson()); + + // Find the chevron icon + final chevronFinder = find.descendant( + of: find.byType(StreamMessageRecipientHeader), + matching: find.byIcon(ZulipIcons.chevron_right)); + + // Get the position of the chevron icon and tap 3px above it + final chevronRect = tester.getRect(chevronFinder); + await tester.tapAt(Offset(chevronRect.center.dx, chevronRect.top - 3)); + + await tester.pump(); + check(pushedRoutes).single.isA().page.isA() + .initNarrow.equals(ChannelNarrow(channel.streamId)); + await tester.pumpAndSettle(); + }); }