project-serum / sol-wallet-adapter

Other
186 stars 93 forks source link

Firefox issues #14

Open morgansson opened 3 years ago

morgansson commented 3 years ago

The adapter on Firefox has a couple of usability issues that I've found so far.

  1. Whenever you connect the wallet, or approve a transaction, a new empty tab is opened on the dApp window.

  2. If you send an approval request from the dApp the wallet popup doesn't focus so you don't realize you need to perform an action on this popup as it's hidden behind the main window.

The steps to reproduce these issues are pretty simple, but if you have any question please let me know.

AC-devon commented 3 years ago

i have issue #2 on chrome as well...

PaulBernier commented 3 years ago

Same here. #2 especially kills the UX because the end-user (and myself :grin:) won't understand why "nothing is happening". I do see the lib is trying to focus the pop up: https://github.com/project-serum/sol-wallet-adapter/blob/master/src/index.js#L120 but somehow it's not effective.

Arrowana commented 3 years ago

I don't have number 2 on chrome, I tried with the example. popup comes in focus just fine. Are you connecting the wallet through a click event? That might be something chrome is blocking if the popup wasn't created by the user somehow.

Edit: popup comes in focus fine, when signing is requested.

PaulBernier commented 3 years ago

For me it happens when I try to sign a transaction immediately after connecting, without a user interaction in between, something like:

        const publicKey = await wallet.connect();
        const trans = new Transaction().add(...);
        const signed = await wallet.signTransaction(trans);
Arrowana commented 3 years ago

@PaulBernier when .connect() resolves, the focus goes back to the dapp. Maybe it tries to bounce between the dapp and back to the popup too fast? What if you insert a delay? Does it suddenly works?

sollet returns focus to parent through window.open('', 'parent'); https://github.com/project-serum/spl-token-wallet/blob/c8527e4fe30af3259f36d6838add668f474a413f/src/pages/PopupPage.js#L104 But this is done after we have called postMessage to tell the dapp we are connected. So it proceed to signTransaction. I suspect popup.focus() is called, then immediately after window.open('', 'parent'). It ends up looking like it never changed focus.

maybe the fix is to give back the focus to the parent before we postMessage to it to confirm we are connected.

PaulBernier commented 3 years ago

I tried with a delay but it doesn't work. It seems it really needs the user to focus the parent window by a click for the pop up to come forward afterward. It could definitely be related to the way the pop up gives back focus to the main window as you mention.

PaulBernier commented 3 years ago

I am still stuck on this issue of the immediate second RPC call not bringing up the background popup (I tried a few hacks on the adapter side but none worked). What do you think of adding an extra parameter focus_back to the RPC call to Sollet that would control if Sollet should give back focus or not at the end of the operation? I am keen to make the modification on the Sollet side. @Arrowana @armaniferrante

Arrowana commented 3 years ago

Don't we just need to reorder the calls? I might give it a go tonight.

Arrowana commented 3 years ago

Mmmh i just gave it a go, used sollet localhost with focusParent() a setTimeout of 1000ms then in its callback postMessage on connect. That doesn't fix it, https://stackoverflow.com/questions/24830249/javascript-pop-up-window-focus-issue it seems like we need user interaction to return the focus, so calling things in a chain like that, is not really doable.

Arrowana commented 3 years ago

The adapter on Firefox has a couple of usability issues that I've found so far.

1. Whenever you connect the wallet, or approve a transaction, a new empty tab is opened on the dApp window.

2. If you send an approval request from the dApp the wallet popup doesn't focus so you don't realize you need to perform an action on this popup as it's hidden behind the main window.

The steps to reproduce these issues are pretty simple, but if you have any question please let me know.

I am still affected by 1. on firefox, that is quite annoying. I'll have another look soon.

billythedummy commented 3 years ago

Any updates on this? This issue still seems to affect firefox