diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d455efcb..3fc7ef8cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [[v3.1.5](https://github.com/multiversx/mx-sdk-dapp/pull/1351)] - 2024-12-17 + +- [Fixed cross window page reload on internal logout](https://github.com/multiversx/mx-sdk-dapp/pull/1350) + ## [[v3.1.4](https://github.com/multiversx/mx-sdk-dapp/pull/1349)] - 2024-12-16 - [Fixed logout doesn't work when `shouldBroadcastLogoutAcrossTabs` is `false`](https://github.com/multiversx/mx-sdk-dapp/pull/1348) diff --git a/package.json b/package.json index 844ca38a5..8435e3940 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@multiversx/sdk-dapp", - "version": "3.1.4", + "version": "3.1.5", "description": "A library to hold the main logic for a dapp on the MultiversX blockchain", "author": "MultiversX", "license": "GPL-3.0-or-later", diff --git a/src/utils/logout.ts b/src/utils/logout.ts index c633b5f8d..7c6a0d1e4 100644 --- a/src/utils/logout.ts +++ b/src/utils/logout.ts @@ -1,3 +1,4 @@ +import { safeWindow } from 'lib/sdkDappUtils'; import { CrossWindowProvider } from 'lib/sdkWebWalletCrossWindowProvider'; import { getAccountProvider, getProviderType } from 'providers'; import { logoutAction } from 'reduxStore/commonActions'; @@ -70,13 +71,17 @@ export async function logout( const url = addOriginToLocationPath(callbackUrl); const location = getWindowLocation(); - const callbackPathname = new URL(decodeURIComponent(url)).pathname; + const { pathname: callbackPathname, origin: callbackOrigin } = new URL( + decodeURIComponent(url) + ); // Prevent page redirect if the logout callbackURL is equal to the current URL // or if is wallet provider + // or if we are in a child tab (redirects via window.assign cause automatic tab close) if ( matchPath(location.pathname, callbackPathname) || - (isWalletProvider && isProviderInitialised) + (isWalletProvider && isProviderInitialised) || + (safeWindow?.opener && callbackOrigin === safeWindow?.origin) ) { preventRedirects(); }