Skip to content

Commit 1461020

Browse files
Merge pull request #211 from richardthe3rd/copilot/sub-pr-209
Use routing helpers in festival selector and preserve current tab
2 parents 201caad + 6bd24ce commit 1461020

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/widgets/festival_menu_sheets.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,24 @@ class FestivalSelectorSheet extends StatelessWidget {
185185
sortedFestivals: festivals,
186186
isSelected: isSelected,
187187
onTap: () {
188+
// Capture current path first, before any state changes
189+
// Default to festival home; override if currently on favorites
190+
String targetPath = buildFestivalHome(festival.id);
191+
try {
192+
final currentPath = GoRouterState.of(context).uri.path;
193+
// Preserve user's tab: if on favorites, stay on favorites
194+
if (currentPath.endsWith('/favorites')) {
195+
targetPath = buildFavoritesPath(festival.id);
196+
}
197+
} catch (e) {
198+
// GoRouterState unavailable (e.g., in tests), keep default path
199+
debugPrint('Festival selector: Unable to get current route, using default: $e');
200+
}
201+
188202
final router = GoRouter.maybeOf(context);
189203
provider.setFestival(festival);
190204
Navigator.pop(context);
191-
router?.go('/${festival.id}');
205+
router?.go(targetPath);
192206
},
193207
onInfoTap: () {
194208
Navigator.pop(context);

0 commit comments

Comments
 (0)