Metamask not opening if has another wallet extensions

Problem: I have Coinbase and MetaMask extensions at Chrome. And when I do simple call authenticate() without params then Coinbase will be opened, not MetaMask.

Expected: Metamask opened instead of Coinbase.

I’ve tried to set selectedProvider but it didn’t help me. Thoughts?

const login = () => {
        const { ethereum } = window as any;

        if (!ethereum?.providers) {
            return undefined;
        }

        if (selectedIndex === 0) {
            const provider = ethereum.providers.find(({ isMetaMask }: any) => isMetaMask);

            ethereum.setSelectedProvider(provider);
            authenticate();
        } else {
            const provider = 'walletconnect';
            authenticate({ provider });
        }
    };

You can look at this.

It didn’t help me. It still opening Coinbase

Can you post your full code now. How do you call login? The solution in that thread to set a provider based on the window.ethereum object does work.

You can test first with two buttons to make sure it works manually (code a bit below in that thread).