fix: open Stripe Express payout management in new tab#3445
fix: open Stripe Express payout management in new tab#3445vishalsaw28 wants to merge 1 commit intodubinc:mainfrom
Conversation
|
@vishalsaw28 is attempting to deploy a commit to the Dub Team on Vercel. A member of the Team first needs to authorize it. |
|
|
📝 WalkthroughWalkthroughThe change modifies how the Stripe account management link opens in the payout methods dropdown component. Instead of navigating within the application using Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/ui/partners/payout-methods-dropdown.tsx (1)
42-54:⚠️ Potential issue | 🟠 Major
window.openin an async callback will be blocked by pop-up blockers.
onSuccessfires after the server action's network round-trip completes, sowindow.openis no longer in the synchronous call stack of the user's click event. Most browsers will silently block this.A common workaround is to open a blank window reference synchronously (during the click), then set its URL once the async response arrives:
Proposed fix
Instead of relying on the
onSuccesscallback, handle the window opening inconnectPayoutwhere the user gesture is still in scope:const connectPayout = async (method: string) => { if (!partner) { return; } if (method === "paypal") { await executePaypalAsync(); } else if (method === "stripe") { - await executeStripeAsync(); + const newWindow = window.open("", "_blank", "noopener,noreferrer"); + const result = await executeStripeAsync(); + if (result?.data?.url && newWindow) { + newWindow.location.href = result.data.url; + } else { + newWindow?.close(); + } } setOpenPopover(false); };And remove the
router.push/window.openfrom theonSuccesscallback (keeping only the error toast inonSuccessif the URL is missing, or moving that check intoconnectPayoutas well).Note: with
noopener, the returnednewWindowreference may benullin some browsers. If that's the case, dropnoopenerfrom the features string (the blank origin window has no meaningfulwindow.openercontext to protect) or fall back towindow.location.assign(data.url)whennewWindowisnull.
|
@vishalsaw28 thanks for the PR! We actually had this before but it gets blocked occasionally by Chrome and other browsers, which leads to user confusion, so we're sticking with this for now. |
Got it, that makes sense thanks for the clarification and context! Appreciate it. |
This updates the Stripe payout account “Manage” action to open Stripe Express in a new tab instead of navigating away from the Dub dashboard.
Since Stripe Express is an external dashboard, opening it in a new tab preserves user context and improves the payout management experience.
Closes #3290
Summary by CodeRabbit