Automatic email field disabled

Up until now I was using email to get otp for users to login via web3auth. But suddenly the field got disabled and the user’s are not able to enter their email to login to the app.

I’m using web3auth modal plug and play SDK.
Here’s the code -

"use client";
import React, {
  createContext,
  ReactNode,
  useContext,
  useEffect,
  useState,
} from "react";
import { CHAIN_NAMESPACES, IProvider, WEB3AUTH_NETWORK } from "@web3auth/base";
import {
  SolanaPrivateKeyProvider,
  SolanaWallet,
} from "@web3auth/solana-provider";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
import { Web3Auth } from "@web3auth/modal";
import {
  Connection,
  LAMPORTS_PER_SOL,
  PublicKey,
  SystemProgram,
  Transaction,
} from "@solana/web3.js";
import { useSnackbar } from "./snackbarContext";
import { useConnectUser } from "@/hooks/api-hooks/useUsers";
import { useAuth } from "./authContext";
import nacl from "tweetnacl";
import naclUtil from "tweetnacl-util";
import { Web3AuthContextProps, Web3AuthProviderProps } from "./interfaces";

const clientId =
  "xyz";

const chainConfig = {
  chainNamespace: CHAIN_NAMESPACES.SOLANA,
  chainId: "0x3",

  // RPC client api endpoint to query or interact with the database
  rpcTarget: "https://api.devnet.solana.com",
  displayName: "Solana Devnet",
  blockExplorerUrl: "https://explorer.solana.com/",
  ticker: "SOL",
  tickerName: "Solana",
};

const privateKeyProvider = new SolanaPrivateKeyProvider({
  config: { chainConfig },
});

// Configure web3auth
const web3auth = new Web3Auth({
  clientId,
  web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
  privateKeyProvider,
});
const openloginAdapter = new OpenloginAdapter({ privateKeyProvider });
web3auth.configureAdapter(openloginAdapter);


const Web3AuthContext = createContext<Web3AuthContextProps | undefined>(
  undefined
);
export const Web3AuthProvider: React.FC<Web3AuthProviderProps> = ({
  children,
}) => {
  const [provider, setProvider] = useState<IProvider | null>(null);
  const [loggedIn, setLoggedIn] = useState(false);
  const { showMessage } = useSnackbar();
  const { connectionMutateAsync } = useConnectUser();
  const [isInitialized, setIsInitialized] = useState(false);
  const { login: loginUser, logout: logoutUser } = useAuth();
  const [isLoading, setIsLoading] = useState(false);

  const init = async () => {
    try {
      await web3auth.initModal();
      setProvider(web3auth.provider);

      if (web3auth.connected) {
        setLoggedIn(true);
      }
      setIsInitialized(true);
    } catch (error) {
      console.error(error);
    }
  };
  useEffect(() => {
    init();
  }, []);

Can anyone help what am I doing wrong here?
Thank you

Hey @singhdon85 can you share the SDK version you are using? Meanwhile, I’ll check on my end.
From what I understood, you are not longer able to use the email field, right?

Yes exactly, i’m not able to type anything inside that field.
Here are the version details -

"@web3auth/base": "^8.8.0",
"@web3auth/modal": "^8.10.1",
"@web3auth/solana-provider": "^8.8.0",
"@web3auth/wallet-services-plugin": "^8.10.2",

Can you update to latest version and try? Is there any console errors you see?

I’ve also updated the packages, still the bug persists.

Does this have something to do with the free plan?

This might not have to do with the free plan because you’re using sapphire_devnet which gives you access to most of the paid features. Can you please share any console errors while trying it on another browser? @singhdon85

Sharing the error log on chrome -

Here I don’t see the error that you showed before. Are you unable to use the email field even here? @singhdon85

Yes, I’m not able to use in on any browser.

Hey @singhdon85,

Could you please try passing a modalConfig explicitly and setting the showOnModal parameter to true?

If that doesn’t resolve the issue, could you please share a link via a tool like jam.dev that provides both console and network logs? This will help me diagnose the problem more effectively.

Do you mind having a look at this recording on gDrive.

I’ve shown the code, and console errors.

Any updates, because now this is so random, it gets enabled/disabled on it’s own

Hey @singhdon85,

I believe we’ve done quite a bit of back and forth on the discourse thread without fully resolving the issue, so a quick debugging session might be beneficial. I recommend joining our Web3Auth Developer Office Hours to get your issue resolved directly. You can find the details and join here: Web3Auth Developer Office Hours.

Since this issue is occurring randomly, my best guess is that it could be due to interference from browser extensions. In the meantime, could you try running it in Chrome’s incognito mode and see if the issue persists there as well?

import React, {
  createContext,
  useContext,
  useEffect,
  useState,
  ReactNode,
} from "react";
import { Web3Auth } from "@web3auth/modal";
import {
  CHAIN_NAMESPACES,
  SafeEventEmitterProvider,
  WEB3AUTH_NETWORK,
} from "@web3auth/base";
import { SolanaPrivateKeyProvider } from "@web3auth/solana-provider";
import { getDefaultExternalAdapters } from "@web3auth/default-solana-adapter";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";

const clientId =
  "";

// Define the structure of the context
interface Web3AuthContextProps {
  provider: SafeEventEmitterProvider | null;
  login: () => Promise<void>;
  logout: () => Promise<void>;
  user: any | null;
}

// Define props for the Web3AuthProvider component to accept children
interface Web3AuthProviderProps {
  children: ReactNode;
}

// Create the context
const Web3AuthContext = createContext<Web3AuthContextProps | undefined>(
  undefined
);

// Custom hook to use the context
export const useWeb3Auth = (): Web3AuthContextProps => {
  const context = useContext(Web3AuthContext);
  if (!context) {
    throw new Error("useWeb3Auth must be used within a Web3AuthProvider");
  }
  return context;
};

// Web3Auth provider component
export const Web3AuthProvider: React.FC<Web3AuthProviderProps> = ({
  children,
}) => {
  const [provider, setProvider] = useState<SafeEventEmitterProvider | null>(
    null
  );
  const [web3auth, setWeb3Auth] = useState<Web3Auth | null>(null);
  const [user, setUser] = useState<any | null>(null);

  const chainConfig = {
    chainId: "0x3",
    chainNamespace: CHAIN_NAMESPACES.SOLANA,
    rpcTarget: "https://api.devnet.solana.com",
    tickerName: "SOLANA",
    ticker: "SOL",
    decimals: 18,
    blockExplorerUrl: "https://explorer.solana.com/?cluster=devnet",
    logo: "https://images.toruswallet.io/sol.svg",
  };

  // Initialize Web3Auth
  useEffect(() => {
    const init = async () => {
      try {
        const solanaPrivateKeyPrvoider = new SolanaPrivateKeyProvider({
          config: { chainConfig: chainConfig },
        });

        const web3auth = new Web3Auth({
          clientId,
          web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
          privateKeyProvider: solanaPrivateKeyPrvoider,
        });

        // Setup external adapaters
        const openloginAdapter = new OpenloginAdapter({
          privateKeyProvider: solanaPrivateKeyPrvoider,
        });
        web3auth.configureAdapter(openloginAdapter);

        setWeb3Auth(web3auth);

        await web3auth.initModal();
        setProvider(web3auth.provider);
      } catch (error) {
        console.error(error);
      }
    };

    init();
  }, []);

  // Login function
  const login = async () => {
    if (!web3auth) return;
    try {
      const providerInstance = await web3auth.connect();
      setProvider(providerInstance);

      const userInfo = await web3auth.getUserInfo();
      setUser(userInfo);
    } catch (error) {
      console.error("Login error:", error);
    }
  };

  // Logout function
  const logout = async () => {
    if (!web3auth) return;
    try {
      await web3auth.logout();
      setProvider(null);
      setUser(null);
    } catch (error) {
      console.error("Logout error:", error);
    }
  };

  return (
    <Web3AuthContext.Provider value={{ provider, login, logout, user }}>
      {children}
    </Web3AuthContext.Provider>
  );
};

I’'m using this very webauthcontext in 2 different projects.
But in 1 it’s the email field is disabled with in other it’s enabled. It’s strange because these are the library versions. Can anyone help. Also to keep in mind the clientid for both the projects is also same.

solana-modal-example@0.1.0 C:\Users\parik\OneDrive\Desktop\BuildSquad\xcrow-web3auth-example\solana-modal-example
├── @web3auth/base@8.12.4
├─┬ @web3auth/default-solana-adapter@8.12.2
│ ├─┬ @web3auth/base-solana-adapter@8.12.2
│ │ └── @web3auth/base@8.12.4 deduped
│ ├── @web3auth/base@8.12.4 deduped
│ ├── @web3auth/solana-provider@8.12.2 deduped
│ └─┬ @web3auth/torus-solana-adapter@8.12.2
│   ├── @web3auth/base@8.12.4 deduped
│   └── @web3auth/solana-provider@8.12.2 deduped
├─┬ @web3auth/modal@8.12.3
│ ├─┬ @web3auth/base-provider@8.12.4
│ │ └── @web3auth/base@8.12.4 deduped
│ ├── @web3auth/base@8.12.4 deduped
│ ├─┬ @web3auth/no-modal@8.12.3
│ │ └── @web3auth/base@8.12.4 deduped
│ └─┬ @web3auth/ui@8.12.2
│   └── @web3auth/base@8.12.4 deduped
├─┬ @web3auth/openlogin-adapter@8.12.4
│ └── @web3auth/base@8.12.4 deduped
└─┬ @web3auth/solana-provider@8.12.2
  └── @web3auth/base@8.12.4 deduped
web3-chess@0.1.0 C:\Users\parik\OneDrive\Desktop\BuildSquad\web3-chess-frontend
├── @web3auth/base@8.12.4
├─┬ @web3auth/default-solana-adapter@8.12.4
│ ├─┬ @web3auth/base-solana-adapter@8.12.4
│ │ └── @web3auth/base@8.12.4 deduped
│ ├── @web3auth/base@8.12.4 deduped
│ ├── @web3auth/solana-provider@8.12.4 deduped
│ └─┬ @web3auth/torus-solana-adapter@8.12.4
│   ├── @web3auth/base@8.12.4 deduped
│   └── @web3auth/solana-provider@8.12.4 deduped
├─┬ @web3auth/modal@8.12.4
│ ├─┬ @web3auth/base-provider@8.12.4
│ │ └── @web3auth/base@8.12.4 deduped
│ ├── @web3auth/base@8.12.4 deduped
│ ├─┬ @web3auth/no-modal@8.12.4
│ │ └── @web3auth/base@8.12.4 deduped
│ ├─┬ @web3auth/openlogin-adapter@8.12.4
│ │ └── @web3auth/base@8.12.4 deduped
│ └─┬ @web3auth/ui@8.12.4
│   └── @web3auth/base@8.12.4 deduped
├─┬ @web3auth/solana-provider@8.12.4
│ └── @web3auth/base@8.12.4 deduped
└─┬ @web3auth/wallet-services-plugin@8.12.4
  └── @web3auth/base@8.12.4 deduped

I’ve got the problem why is it happening but not sure how to fix it, the issue is.
the login is being called inside an MUI modal. That mean after the web3auth modal is open, there’s a custom modal beneath it.

How to resolve it?

Hey @singhdon85,

The issue is likely caused by the MUI modal conflicting with the Web3Auth modal. Try these solutions:

  1. Close the MUI modal before opening Web3Auth to prevent focus conflicts.

  2. Increase the z-index of the Web3Auth modal to layer it above the MUI modal. (Login Modal | Documentation | Web3Auth)

  3. Disable focus trapping in the MUI modal by using disableEnforceFocus:

    <Modal disableEnforceFocus>
      {/* Your modal content */}
    </Modal>
    

This should resolve the issue! Let me know how it goes.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.