How to connect to either Metamask or Coinbase wallet?

How do you specify connection with Coinbase Wallet and Metamask separately?

Right now when using window.ethereum.enable() both the Metamask and Coinbase Wallet extensions popup. I would like two separate buttons, one for Metamask and the other for Coinbase Wallet.

My code:

const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
const web3 = createAlchemyWeb3(alchemyKey);

export const connectWallet = async () => {
    if (window.ethereum) { //check if Metamask is installed 
      try {
            const address = await window.ethereum.enable(); //connect Metamask
      }
   }
})

Solution 1:

From this discussion, it seems like you may be able to use a different Metamask request method to force connection selection:

  const connectWallet = async () => {
    if (window.ethereum) { //check if Metamask is installed 
      try {
        const address = await window.ethereum.request({
          method: 'wallet_requestPermissions',
          params: [{ eth_accounts: {}}]
        }); 
      } catch (error) {
        console.log(error);
      }
    }
  }

The wallet_requestPermissions seems to do the trick.