Skip to content

Commit

Permalink
fix: ensure blank tab isn't left behind after connecting on iOS (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Jun 27, 2022
1 parent b495187 commit d905271
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shaggy-doors-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rainbow-me/rainbowkit': patch
---

Fix issue on iOS in non-Safari browsers and WebViews where a blank tab is left behind after connecting via WalletConnect
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ function WalletButton({ wallet }: { wallet: WalletConnector }) {
setWalletConnectDeepLink({ mobileUri, name });

if (mobileUri.startsWith('http')) {
window.open(mobileUri, '_blank', 'noreferrer,noopener');
// Workaround for https://github.com/rainbow-me/rainbowkit/issues/524.
// Using 'window.open' causes issues on iOS in non-Safari browsers and
// WebViews where a blank tab is left behind after connecting.
// This is especially bad in some WebView scenarios (e.g. following a
// link from Twitter) where the user doesn't have any mechanism for
// closing the blank tab.
// For whatever reason, links with a target of "_blank" don't suffer
// from this problem, and programmatically clicking a detached link
// element with the same attributes also avoids the issue.
const link = document.createElement('a');
link.href = mobileUri;
link.target = '_blank';
link.rel = 'noreferrer noopener';
link.click();
} else {
window.location.href = mobileUri;
}
Expand Down

2 comments on commit d905271

@vercel
Copy link

@vercel vercel bot commented on d905271 Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d905271 Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.