The styling for material UI's default endAdornment is lacking accuracy

My Autocomplete component from material UI v5 includes a default endAdornment icon. However, the icon appears to have the CSS property top:unset, causing it to be styled incorrectly.

Here is the code for rendering the Autocomplete:

<Grid item xs={3}>
  <FormControl style={{ backgroundColor: "#fff !important" }}>
    <Autocomplete
      renderInput={(props) => {
        return (
          <TextField
            {...props}
            label={`${translateFullContent(
              t,
              i18n,
              `ActionSelector.shiftGroup`,
            )}`}
            variant="outlined"
            placeholder="Select a shift group"
            sx={{
              backgroundColor: "#fff",
            }}
          />
        );
      }}
      style={{
        width: "300px",
      }}
      options={shiftGroupList}
      getOptionLabel={(option: ShiftGroupListInterface) => {
        return option.name;
      }}
      onChange={(
        _event: React.SyntheticEvent<Element, Event>,
        newValue: ShiftGroupListInterface | null,
      ) => {
        if (newValue) {
          handleShiftGroupSelection(newValue);
        }
      }}
      value={selectors.shiftGroup}
      isOptionEqualToValue={(option, value) => {
        if (option.id === value.id) {
          return true;
        }
        return false;
      }}
    />
  </FormControl>
</Grid>;

The functionality of the Autocomplete appears to be working correctly. The only issue is the position of the dropdown arrow in the endAdornment, which currently looks like this:

https://i.sstatic.net/jsB9t.png

After inspecting the CSS of the .end-Adornment class, I found that the problem is due to the top:unset property in the CSS. Removing this property and applying top: 50% fixes the issue, as shown in this image:

https://i.sstatic.net/Gq04x.png

Here is how it looks after removing top:unset:

https://i.sstatic.net/m0bQa.png

Answer №1

To solve this issue, I implemented extra styling for the endAdornment of the TextField. I made sure to specifically target the MuiAutocomplete-endAdornment class and the MuiIconButton-root class to set the CSS top value to auto, overriding any previous value of unset.

 sx={{
     '& .MuiAutocomplete-endAdornment .MuiIconButton-root':{
          top: 'auto' // overriding the previous value of top:unset
      }
 }}

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

Tips for creating an asynchronous Redux test involving Firebase authentication

I'm struggling to figure out how to write a test for this particular issue auth.js export const onLogin = ({email, password}) => async dispatch => { try { const user = await firebase.auth().signInWithEmailAndPassword(email, password) ...

Tips for submitting a request following a change in the variable

I am in the process of developing a React application and I have implemented Auth0 for authentication. My goal is to initiate an HTTP request upon page refresh, but only if the variable isLoading is false. This way, I can access the user object once the ...

Use the .map method to transform JSON data retrieved from Prisma within

Trying to work with mapping a JSON object in a Next.js class component using data from Prisma. I've had to stringify the data from Prisma to avoid a serialization error on the date parameter. I know I can't directly use .map on this.props.commen ...

Other options to consider besides using flex wrapping

Is it possible to use other methods to wrap these image items with the display: flex; property besides using the flex-wrap property? Are there alternative approaches available? body { margin: 0px; } img {} h1 {} p {} a { background-color: #ddd; ...

What is the best way to show hidden content within a masked div, similar to a tooltip?

In an icon-based menu, a grid consists of several <div> elements. Each element is empty with general CSS styling and inline CSS to set the mask effect. The purpose of using images as masks is to allow the icons to be colored in different ways by cha ...

Having trouble customizing the active state of a react router navlink using css modules in React?

Objective I am attempting to add styles to the active route in a sidebar using css modules while still maintaining the base styles by assigning 2 classes. This is the code I have tried: <NavLink to={path} className={` ${classes.nav_ ...

Creating a Unique Visual Design for Toggle Buttons

I am encountering issues while trying to achieve a custom styling for a Toggle Button in my React application. The current implementation involves using Material-UI and styled-components. Current Approach: To customize the appearance of the Toggle Button ...

Encountering iOS 10 freezing issues when scrolling through an HTML list that is styled with -webkit-overflow-scrolling: touch

Overview This specific issue pertains to a potential freeze that occurs when scrolling through a <ul /> element that has been styled using CSS, specifically with the property -webkit-overflow-scrolling: touch on the Safari browser of iOS. Related Pr ...

How does the frontend interact with JWT to manage authentication?

I'm diving into the world of web development. I successfully created a backend using Django Rest Framework and have opted to utilize JWT for authentication. Now, my next challenge is connecting this backend to my frontend in React. However, I find my ...

How can I modify the behavior of the "more filters" button and sheet in Shopify Polaris React + Rails?

technology: react-rails gem v 2.4.7 react v 16.4.2 "@shopify/polaris": "4.2.1" Issue: While implementing the polaris Filters component to filter a table according to the documentation, I encountered a problem. My setup resembles the 'Filtering wit ...

Is it feasible to exclusively apply Twitter Bootstraps .navbar-fix-to-top on mobile devices?

I am working on a website using Twitter Bootstrap 3 and I have implemented the following navbar: <div class="col-xs-12 col-md-10 col-md-offset-1"> <nav class="navbar navbar-inverse" role="navigation"> <div class="navbar-header"> ...

Troubleshooting error in Next.js when adding "sizes" attribute to Image component with layout set to "responsive"

When you use the following code: <Image src="/images/lorem.jpg" height={150} width={850} layout="responsive" sizes="50vw" // <== ...

The anchor tag seems to be malfunctioning within the div container

<style type="text/css> .xyz { position: absolute; top: 120px; left: 160px; z-index: -1; } #container { position: relative; overflow: visible; opacity: .3; } </style> <body> <div> <video i ...

Is there a way to check if a date of birth is valid using Regular Expression (RegExp) within a react form?

const dateRegex = new RegExp('/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.] (19|20)\d\d+$/') if (!formData.dob || !dateRegex.test(formData.dob)) { formErrors.dob = "date of birth is required" ...

When you select one of the autofill suggestions, the background color of the MUI TextField component will switch to white

Alright, here's the issue at hand. The main problem is indicated by the title of this post. I have a component that consists of a standard MUI text field: <TextField onChange={(e) => { handleSetUserData(e); }} ...

What could be causing the tooltip to malfunction in jQuery?

The tooltip is not appearing as expected, only the title is displaying in the browser. What can be done to fix this? Below is the code snippet: HTML Code: <form action="/validate.php" method="post" id="myform"> <table width="100%" border="1"> ...

Struggling to establish a functioning proxy in my React and Node application

In the process of developing a react client app with a node.js express backend, I have encountered an issue related to project structure. https://i.sstatic.net/8rID0.png The client app includes a proxy configuration in its package.json file: "proxy": "h ...

A guide on verifying the percentage value of an element's height in Selenium with Java

I was able to retrieve the element's height in pixels using: element.getCssValue("height") However, the height returned was: Height: 560px What I actually need is for the height to be displayed as: Height: 100% Or perhaps Height: 50% ...

What is the best way to access a component generated using the .map() function from a separate component?

My objective is to create a grid of toggle buttons that store their selected values in an array. This array will then be used to display another row of buttons based on the selections. Once a button in the new row is chosen, it should deselect the corresp ...

Flexbox design that adapts responsively to display 3 items per row, shifting to 2 items and finally

I have a segment with six elements. For desktop, I would like to display 3 items per row; for medium devices, 2 items per row; and for mobile devices, only 1 item per row. <div class="flex-container"> <div>1</div> <div>2</d ...