Fix: Prevent Family Wallet Connection Pop-up from Being Blocked
This PR addresses an issue where the Family Wallet connection pop-up was being blocked by browsers due to it not being triggered by a direct user interaction.
Changes Made
- Improved the connection flow to ensure pop-ups are triggered properly
π₯ Demo
https://github.com/user-attachments/assets/331be9f4-489a-4dd8-aea9-f109fae3f079
A video has been created showing the difference between:
- β The old flow β where pop-ups could be blocked
- β The new flow β where the connection works seamlessly
π Testing
Tested across:
- Chrome
- Safari
@GianlucaMinoprio is attempting to deploy a commit to the Avara Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git βοΈ
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| connectkit-testbench | β Ready (Inspect) | Visit Preview | π¬ Add feedback | May 21, 2025 0:05am |
hey @GianlucaMinoprio, thanks for the PR!
this looks to have some regression on desktop due to it calling connect() again once the route has changed. we would need an isMobile check wrapped around this for this logic to work
example:
if(isMobile) {
connect({ connector });
} else {
context.setRoute(routes.CONNECT);
}
https://github.com/user-attachments/assets/2279a8bc-b9ec-4939-94d3-db634042eb96
Because connect is being called twice in this case, I recommend moving the logic into a useEffectof ConnectWithInjector like this:
if (wallet?.connector.id !== 'familyAccountsProvider') {
connectTimeout = setTimeout(runConnect, 600);
}
https://github.com/user-attachments/assets/9a4e89b1-1b67-44f9-a3e2-af15c284408a
For the familyAccountsProvider, I believe the connection should remain tied to the button click. This ensures consistent behavior across the Apple ecosystem and helps avoid the pop-up being blocked. On both iOS and desktop Safari, pop-ups triggered outside of a direct user interaction (like a button click) are blocked, resulting in a failed connection attempt. Itβs frustrating UX when a smooth pop-up could have worked.
Right now, the only issue is that Iβm unable to detect the error message that rejects the connection inside ConnectWithinjector. Other than that, everything is working well.
Pushed the update @lochie, if youβre able to find a way to detect when the connection is canceled, that would be awesome. Let me know if I can help debug!
I've added a small change so that the direct connect from the button only work for Family Account:
if (connector.id === 'familyAccountsProvider') {
connect({ connector: connector });
}
In the useConnect() of Connectors we should add the management of the User rejected request and sync with the UI using the context.