Skip to content

Commit 2e56c31

Browse files
fix(mobile): track replaced routes above the conversation
_DetailRoutes now handles didReplace, so a route that arrives via pushReplacement takes Back before the thread pane and closes the thread like a push would. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Albrecht <139878933+FL-TechCouncil@users.noreply.github.com>
1 parent bc9307b commit 2e56c31

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎mobile/lib/shared/widgets/adaptive_conversation_pane.dart‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,16 @@ class _DetailRoutes extends NavigatorObserver {
11131113
}
11141114

11151115
@override
1116-
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
1116+
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) =>
1117+
_arrive(route);
1118+
1119+
@override
1120+
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
1121+
_above.remove(oldRoute);
1122+
if (newRoute != null) _arrive(newRoute);
1123+
}
1124+
1125+
void _arrive(Route<dynamic> route) {
11171126
// Declarative pages are the pane's own selection and placeholder.
11181127
if (route.settings is Page) return;
11191128
_above.add(route);

‎mobile/test/shared/widgets/conversation_tablet_layout_test.dart‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:buzz/features/channels/media_viewer_page.dart';
24
import 'package:buzz/shared/theme/theme.dart';
35
import 'package:buzz/shared/widgets/adaptive_conversation_pane.dart';
@@ -468,6 +470,24 @@ void main() {
468470
await tester.pumpAndSettle();
469471
expect(find.byType(MediaImageViewerPage), findsNothing);
470472
expect(find.text('Thread content'), findsOneWidget);
473+
// A viewer that replaces another still takes Back before the thread.
474+
await tester.tap(find.text('Open image'));
475+
await tester.pumpAndSettle();
476+
unawaited(
477+
Navigator.of(
478+
tester.element(find.byType(MediaImageViewerPage)),
479+
).pushReplacement(
480+
buildImageViewerRoute(
481+
imageUrl: 'https://example.org/other.png',
482+
heroTag: 'tablet-other',
483+
),
484+
),
485+
);
486+
await tester.pumpAndSettle();
487+
await tester.binding.handlePopRoute();
488+
await tester.pumpAndSettle();
489+
expect(find.byType(MediaImageViewerPage), findsNothing);
490+
expect(find.text('Thread content'), findsOneWidget);
471491
await tester.tap(find.text('Open linked page'));
472492
await tester.pumpAndSettle();
473493
expect(find.text('Linked page'), findsOneWidget);

0 commit comments

Comments
 (0)