diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/util/extensions/ConfigExtensions.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/util/extensions/ConfigExtensions.kt index 5fd84c5c0c..7c81521590 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/util/extensions/ConfigExtensions.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/util/extensions/ConfigExtensions.kt @@ -164,11 +164,19 @@ fun List.handleClickEvent( ApplicationWorkflow.LAUNCH_INSIGHT_SCREEN -> navController.navigate(MainNavigationScreen.Insight.route) ApplicationWorkflow.DEVICE_TO_DEVICE_SYNC -> startP2PScreen(navController.context) - ApplicationWorkflow.LAUNCH_MAP -> - navController.navigate( - MainNavigationScreen.GeoWidgetLauncher.route, - bundleOf(NavigationArg.GEO_WIDGET_ID to actionConfig.id), - ) + ApplicationWorkflow.LAUNCH_MAP -> { + val mapFragmentDestination = MainNavigationScreen.GeoWidgetLauncher.route + val isMapFragmentExists = + navController.currentBackStack.value.any { it.destination.id == mapFragmentDestination } + if (isMapFragmentExists) { + navController.popBackStack(mapFragmentDestination, false) + } else { + navController.navigate( + resId = mapFragmentDestination, + args = bundleOf(NavigationArg.GEO_WIDGET_ID to actionConfig.id), + ) + } + } ApplicationWorkflow.LAUNCH_DIALLER -> { val actionParameter = interpolatedParams.first() val patientPhoneNumber = actionParameter.value