Skip to content

Commit 0c78b04

Browse files
committed
fix(Popover): close on param-only browser navigation changes
1 parent 2df430a commit 0c78b04

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/components/Popover/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,23 @@ function Popover(props: PopoverProps) {
7272

7373
let isActive = true;
7474
let baselineKey: string | undefined;
75+
let baselineParamsStr: string | undefined;
7576
// Holds the unsubscribe function once the subscription is set up asynchronously.
7677
const unsubscribeRef: {current: (() => void) | undefined} = {current: undefined};
7778

7879
Navigation.isNavigationReady().then(() => {
7980
if (!isActive) {
8081
return;
8182
}
82-
baselineKey = navigationRef.getCurrentRoute()?.key;
83+
const initialRoute = navigationRef.getCurrentRoute();
84+
baselineKey = initialRoute?.key;
85+
baselineParamsStr = JSON.stringify(initialRoute?.params);
8386
unsubscribeRef.current = subscribeToRootNavigation(() => {
8487
if (!isActive || baselineKey === undefined) {
8588
return;
8689
}
87-
if (navigationRef.getCurrentRoute()?.key !== baselineKey) {
90+
const currentRoute = navigationRef.getCurrentRoute();
91+
if (currentRoute?.key !== baselineKey || JSON.stringify(currentRoute?.params) !== baselineParamsStr) {
8892
onClose?.();
8993
}
9094
});

0 commit comments

Comments
 (0)