Need help with styling for disabled autocomplete? Check out the attached image

I'm currently working with material-ui and react to create a basic form. Everything is functioning properly except for a small UI issue that I can't seem to figure out how to resolve. When I utilize the browser's auto-complete feature, the input field remains highlighted. Despite my efforts to inspect the CSS using Chrome DevTools, I haven't been able to identify what is causing this.

This problem persists across all textfields at the moment, even after removing any custom styles applied to the component.

It's difficult to articulate in words, so I've included some screenshots below:

Before:

After:

The highlighting remains even after clicking away and selecting another element. Interestingly, this behavior doesn't occur when typing in a password field.

Component:

const useStyles = makeStyles(theme => ({
    border: {
    '& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline': {
      borderColor: theme.palette.secondary.main
    },
    width: '75%',
    alignSelf: 'center'
  },
})

const LoginForm = () => {
    const classes = useStyles();

    <TextField
          name='password'
          type='password'
          value={formik.values.password}
          className={classes.border}
          variant='outlined'
          label='Password'
          onChange={formik.handleChange}
          onBlur={formik.handleBlur}
          error={formik.touched.password && Boolean(formik.errors.password)}
          helperText={formik.touched.password ? formik.errors.password : ''}
        />
}

Answer №1

After including the following code snippet in my theme.js file, the issue I was experiencing resolved:

const customTheme = {
    overrides: {
        MuiOutlinedInput: {
          input: {
            '&:-webkit-autofill': {
              WebkitBoxShadow: '0 0 0 100px #303030 inset',
              WebkitTextFillColor: '#fff',
            },
          },
        },
      }
    };

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

React JS - State values are not persisting and rendering properly upon clicking

Recently, I followed a step-by-step tutorial on creating a todo list using functional components. However, I encountered an issue when attempting to delete or mark items as complete in the list. In both the deleteHandler and completeHandler functions, I tr ...

Issue observed with the functionality of checkAll and uncheckAll after a user interacts with a single checkbox

After completing an Angular course on Udemy, I decided to implement a custom checkbox in my Angular app. However, I encountered an issue where the UI was not updating properly when using checkAll and uncheckAll functions after the user interacted with an i ...

What is the best way to add padding to each line within a block of text containing multiple lines

My <span> tag has a background color and left and right padding applied to it. However, the padding is only visible at the beginning and end of the <span>, not on each line when the text wraps onto multiple lines. Is there a way to add padding ...

Navigating the new Material UI V5: Unlocking theme properties types in @mui/material version 5

Since upgrading from @material-ui version 4 to version 5, I have been having trouble accessing the theme properties. Can anyone offer insight on how to resolve this issue? Material-ui v4: I had no issues accessing the theme properties! https://i.stack.img ...

Enabling communication between App.js and a separate class in React

How can I integrate React Scheduler with JSON data in my app and pass shifts and functions from App.js to DataSheet.js for updating the data? Is there a more efficient way to enable database updates directly from DataSheet? App.js: import React from &apos ...

Showing Information in an HTML Table

I am new to the world of PHP programming and constantly searching for solutions to my problems. If anyone has any ideas, please share them - I greatly appreciate any help in solving this issue. Within my database table, I have data structured as follows: ...

Altering the Size of Text in HTML

Currently I am working on my website and the title appears as follows <h1><font face="tempus sans itc" color="White"><div style="text-align:center">Welcome To My Website. View My Projects Here</h1></div> Is there a way to in ...

The function componentWillReceiveProps in the lifecycle is invoked several times

I have been following Tyler McGinnis' React curriculum to learn how to build a weather app. I've encountered a strange behavior that I'm having trouble debugging. It seems like I might be missing some key information or making a simple mista ...

Rotating and moving two boxes using CSS3 transformations

I have two boxes, each measuring 200px by 200px, that I would like to animate using CSS animations. The first box (upper box) should rotate from rotateX(0deg) to rotateX(90deg) with a transform-origin of center top. The second box should follow the bottom ...

The MDX syntax highlighting feature seems to be malfunctioning in Next.js

After importing the plugin @mapbox/rehype-prism, I noticed that syntax highlighting is not functioning as expected. //next.config.js const rehypePrism = require("@mapbox/rehype-prism"); const withMDX = require("@next/mdx")({ extens ...

What is the reason that the 400 status code consistently causes the enter catch block to execute when using axios?

In the frontend of my website, there is a contact form with three fields -> name, email, message. These fields are then sent to the backend using Axios. If a user fails to fill out any of the required fields, they should see a message saying "please f ...

Selecting just a single response as the correct solution

I am currently in the process of developing a Q&A website inspired by Stack Overflow. However, I have encountered an issue where when I try to mark an answer as accepted, it ends up marking every answer as accepted. My goal is to allow users to only ma ...

What steps can be taken to ensure a user remains logged in even after a page reload in a Next.js app utilizing Firebase authentication?

I have implemented Firebase authentication for user login using GoogleAuthProvider. However, I am encountering an issue where the user gets logged out on page reload. Is there a way to persist the user without storing any credentials in localStorage? Belo ...

I would like to share tips on integrating React.js with a backend through React Hooks and the process of deploying the application on Heroku

Looking to integrate the React front-end framework with my backend express.js and EJS using React Hooks. I am familiar with using app.get() in Express for handling server requests, but unsure how to coordinate that with starting a React server on localh ...

Transferring the selected option from a drop-down menu to a PHP page using an HTML form

I'm currently working on developing an HTML form that will send the user's question and the selected topic to a PHP page. The topics are retrieved from a MySQL database using PHP. My goal is to submit the chosen topic value from a dropdown menu, ...

Problem encountered when attempting to set and retain default values in a PHP select box

<form name="search" method="post" > Seach for: <input type="text" name="find" value="<?php echo (isset($_POST['find']) ? $_POST['find'] : ''); ?>" /> in <Select NAME="field"> <Option VALUE="catego ...

What could be causing my click() function to only work properly after resizing?

It's driving me crazy. The code snippet below works perfectly, but not in my project. Only the code in the resize() function seems to work. When I resize the window, everything functions as expected - I can add and remove the 'open' class by ...

Safari does not support onunload when the page is closing

<body onunload="notReady()"> <script > function notReady(){ alert("closing") } </script> </body> It seems that the script works only when refreshing the page or clicking a link on the page, but not when closing the pa ...

Flexslider optimized for mobile devices

I am currently using the Sparkling theme on a Wordpress website. This particular theme utilizes Flexslider within a div at the top of the page. Each slide featured in the slider includes an image, as well as a div containing a post title and excerpt. The ...

Switch the visibility of an HTML input styled as a "spinner"

I have managed to create a CSS-based method for toggling the visibility of span or input elements depending on whether a radio button is checked. I got inspired by this insightful question on Stack Overflow. However, I encountered an issue where this togg ...