From d17ef8b28ee0f2d0dc4dbd508804beb4ca576bd3 Mon Sep 17 00:00:00 2001 From: Jay Ohms Date: Wed, 20 Oct 2021 07:39:58 -0400 Subject: [PATCH] When resetting the NavHostFragment, use the navigation visit callback to ensure that the WebView is detached first. This allows the normal visit flow to work properly when the nav graph is recreated. --- .../turbo/session/TurboSessionNavHostFragment.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/turbo/src/main/kotlin/dev/hotwire/turbo/session/TurboSessionNavHostFragment.kt b/turbo/src/main/kotlin/dev/hotwire/turbo/session/TurboSessionNavHostFragment.kt index 87a753dd..2385ac2e 100644 --- a/turbo/src/main/kotlin/dev/hotwire/turbo/session/TurboSessionNavHostFragment.kt +++ b/turbo/src/main/kotlin/dev/hotwire/turbo/session/TurboSessionNavHostFragment.kt @@ -43,10 +43,12 @@ abstract class TurboSessionNavHostFragment : NavHostFragment() { } fun reset(onReset: () -> Unit = {}) { - currentNavDestination.clearBackStack { - session.reset() - initControllerGraph() - onReset() + currentNavDestination.delegate().navigator.onNavigationVisit { + currentNavDestination.clearBackStack { + session.reset() + initControllerGraph() + onReset() + } } }