From e6ebaf91eae41e2376a3f61034d9000d721bb009 Mon Sep 17 00:00:00 2001 From: dominictb <tb-dominic@outlook.com> Date: Sat, 1 Jun 2024 23:55:13 +0700 Subject: [PATCH 1/2] chore: remove all selection ranges during navigation --- src/libs/Navigation/NavigationRoot.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx index 06a3dce8d59a..0584bf22a49f 100644 --- a/src/libs/Navigation/NavigationRoot.tsx +++ b/src/libs/Navigation/NavigationRoot.tsx @@ -135,6 +135,10 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N // We want to clean saved scroll offsets for screens that aren't anymore in the state. cleanStaleScrollOffsets(state); + + // clear all window selection on navigation + // this is to prevent the selection from persisting when navigating to a new page in web + window?.getSelection()?.removeAllRanges(); }; return ( From e0e797f2990b10ec2a6fc38daa1e5b65204a2ee2 Mon Sep 17 00:00:00 2001 From: dominictb <tb-dominic@outlook.com> Date: Fri, 7 Jun 2024 02:32:05 +0700 Subject: [PATCH 2/2] fix: use optional chain to avoid crash on native Signed-off-by: dominictb <tb-dominic@outlook.com> --- src/libs/Navigation/NavigationRoot.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx index 0584bf22a49f..9e1eb348451b 100644 --- a/src/libs/Navigation/NavigationRoot.tsx +++ b/src/libs/Navigation/NavigationRoot.tsx @@ -138,7 +138,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N // clear all window selection on navigation // this is to prevent the selection from persisting when navigating to a new page in web - window?.getSelection()?.removeAllRanges(); + // using "?" to avoid crash in native + window?.getSelection?.()?.removeAllRanges?.(); }; return (