From 5e74d626d09444251b719413d09035747992867a Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Thu, 13 Feb 2025 18:03:49 +0530 Subject: [PATCH] Fixed: Opening SearchItem and FindInPage triggers again when switching back to the reader fragment. * The issue occurred because when moving to another fragment, the `ReaderScreen` remained in the backstack and was not fully destroyed along with its data. Additionally, we were storing the `SearchItem` and `FIND_IN_PAGE` query in variables to perform these actions after restoring tabs. As a result, when reopening the `ReaderScreen`, the tabs were restored, and these variables retained their values, triggering the related actions again. * To fix this, we have cleared these variables when the fragment is destroyed, as keeping them is unnecessary when the user navigates away from the reader screen. --- .../java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt index ce948c2837..232c57e9bb 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt @@ -1228,6 +1228,8 @@ abstract class CoreReaderFragment : override fun onDestroyView() { super.onDestroyView() + findInPageTitle = null + searchItemToOpen = null restoreTabsSnackbarCallback = null try { coreReaderLifeCycleScope?.cancel()