Skip to content

Commit 186948c

Browse files
msglist: Fix channel header tap behaviour in multi-channel narrows
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 #1368.
1 parent a5af8d3 commit 186948c

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,4 +1470,46 @@ void main() {
14701470
..status.equals(AnimationStatus.dismissed);
14711471
});
14721472
});
1473+
1474+
group('channel header navigation in multi-channel narrows', () {
1475+
for (final narrow in [
1476+
const CombinedFeedNarrow(),
1477+
const MentionsNarrow(),
1478+
const StarredMessagesNarrow(),
1479+
]) {
1480+
testWidgets("navigates to ChannelNarrow when tapping empty space in channel header area in ${narrow.runtimeType}", (tester) async {
1481+
final pushedRoutes = <Route<void>>[];
1482+
final navObserver = TestNavigatorObserver()
1483+
..onPushed = (route, prevRoute) => pushedRoutes.add(route);
1484+
final channel = eg.stream();
1485+
final message = eg.streamMessage(stream: channel);
1486+
await setupMessageListPage(tester,
1487+
narrow: narrow,
1488+
streams: [channel],
1489+
subscriptions: [eg.subscription(channel)],
1490+
messages: [message],
1491+
navObservers: [navObserver]);
1492+
1493+
assert(pushedRoutes.length == 1);
1494+
pushedRoutes.clear();
1495+
1496+
connection.prepare(json: eg.newestGetMessagesResult(
1497+
foundOldest: true, messages: [message]).toJson());
1498+
1499+
// Find the stream name text
1500+
final streamNameFinder = find.descendant(
1501+
of: find.byType(StreamMessageRecipientHeader),
1502+
matching: find.text(channel.name));
1503+
1504+
// Get the position of the stream name and tap 3px above it
1505+
final streamNameRect = tester.getRect(streamNameFinder);
1506+
await tester.tapAt(Offset(streamNameRect.center.dx, streamNameRect.top - 3));
1507+
1508+
await tester.pump();
1509+
check(pushedRoutes).single.isA<WidgetRoute>().page.isA<MessageListPage>()
1510+
.initNarrow.equals(ChannelNarrow(channel.streamId));
1511+
await tester.pumpAndSettle();
1512+
});
1513+
}
1514+
});
14731515
}

0 commit comments

Comments
 (0)