Skip to content

Commit 9906ef5

Browse files
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.
1 parent a5af8d3 commit 9906ef5

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/widgets/message_list.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ class StreamMessageRecipientHeader extends StatelessWidget {
10831083
?? zulipLocalizations.unknownChannelName; // TODO(log)
10841084

10851085
streamWidget = GestureDetector(
1086+
behavior: HitTestBehavior.opaque,
10861087
onTap: () => Navigator.push(context,
10871088
MessageListPage.buildRoute(context: context,
10881089
narrow: ChannelNarrow(message.streamId))),

test/widgets/message_list_test.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,4 +1470,38 @@ void main() {
14701470
..status.equals(AnimationStatus.dismissed);
14711471
});
14721472
});
1473+
1474+
testWidgets("navigates to ChannelNarrow when tapping the empty space in the channel part area of the CombinedFeedNarrow header", (tester) async {
1475+
final pushedRoutes = <Route<void>>[];
1476+
final navObserver = TestNavigatorObserver()
1477+
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
1478+
final channel = eg.stream();
1479+
final message = eg.streamMessage(stream: channel);
1480+
await setupMessageListPage(tester,
1481+
narrow: const CombinedFeedNarrow(),
1482+
streams: [channel],
1483+
subscriptions: [eg.subscription(channel)],
1484+
messages: [message],
1485+
navObservers: [navObserver]);
1486+
1487+
assert(pushedRoutes.length == 1);
1488+
pushedRoutes.clear();
1489+
1490+
connection.prepare(json: eg.newestGetMessagesResult(
1491+
foundOldest: true, messages: [message]).toJson());
1492+
1493+
// Find the chevron icon
1494+
final chevronFinder = find.descendant(
1495+
of: find.byType(StreamMessageRecipientHeader),
1496+
matching: find.byIcon(ZulipIcons.chevron_right));
1497+
1498+
// Get the position of the chevron icon and tap 3px above it
1499+
final chevronRect = tester.getRect(chevronFinder);
1500+
await tester.tapAt(Offset(chevronRect.center.dx, chevronRect.top - 3));
1501+
1502+
await tester.pump();
1503+
check(pushedRoutes).single.isA<WidgetRoute>().page.isA<MessageListPage>()
1504+
.initNarrow.equals(ChannelNarrow(channel.streamId));
1505+
await tester.pumpAndSettle();
1506+
});
14731507
}

0 commit comments

Comments
 (0)