Difficulty in adjusting the height of the popover menu that appears when using the Select Validator in Material UI

I am having trouble adjusting the height of a popover that emerges from a select validator form in Material UI. Despite attempting various methods, including adding the following CSS to the main class:

'& .MuiPopover-paper': {
  height: '330px',
},

None of my attempts have been successful. Interestingly, I am able to modify the height of the .MuiPopover-paper element when I inspect it using the browser console. Changes made there reflect as expected, showing the desired outcome. It appears that I am unable to target the element correctly in the stylesheet or code, as my various attempts have proven ineffective.

Below is the JS/JSX code snippet:

<SelectValidator
    id="color" 
    inputRef={this.formRefs.color}
    value={color}
    onChange={handleChangeByEvent}
    variant="outlined"
    name='color'
    className={classes.boder}
    validators={['required']}
    errorMessages={["Please select your vehicle's color"]}
>
        <MenuItem value="" className={classes.option}>
            <em>None</em>
        </MenuItem>
        {
            vehicleColors.map(color => {
                return <MenuItem key={color.id} value={color} className={classes.option}>       
                {color.name}</MenuItem>
            })
         }
</SelectValidator>

And here is the corresponding CSS code:

border: {
    width: '100%',
    margin: '7px 0',
    borderRadius: '1px',
    color: '#333',
    fontSize: '14px',
    '& .MuiSelect-iconOutlined': {
        top: 'auto',
        fontSize: '24px',
        color: '#fff',
        marginRight: '10px',
        backgroundImage: `url(${downImg})`,
    },
    '& .MuiSelect-select': {
        height: '48px',
        width: '100%',
        display: 'flex',
        alignItems: 'center',
        border: 'solid 1px #6e6e6e',
        padding: '0 14px',
        backgroundColor: '#ffffff',
        fontFamily: 'FordAntenna-Regular',
        color: '#333',
        fontSize: '14px',
        borderRadius: '3px',
    },
},

Answer №1

After some experimentation, I was able to figure this out. The popover in question is not directly connected to the root element or any of its children. Instead, it is dynamically created and rendered using Material-ui classes when accessed at runtime.

As a result, in order to customize the appearance of the popover, it is necessary to override the settings for the built-in classes.

One way to achieve this is by creating a styleOverrides.css file that contains the following code (make sure it is a .css file, as adding this code to your styles.js file will not have the desired effect). Then, import the .css file into the component where the popover you wish to modify is generated.

.MuiMenu-paper.MuiPopover-paper {
    max-height: 300px; //or any other attribute you wish to modify
}

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

Real-time filtering in personalized dropdown menu with search input

I have been attempting to create a custom list filter for input using a computed property. In one file, I am developing a widget, while in another file, I am implementing it. Below is the code snippet from the widget creation file: <template> ...

How can I click on an item when using pagination?

When using react.js, I am encountering a difficult-to-understand error. My component works fine without pagination - it displays all items and allows you to click on them. Pagination is working properly as well, but the issue arises when trying to click on ...

What are the distinctions between utilizing util.inherits() and prototypes for inheritance in node.js?

The method util.inherits() allows for the inheritance of methods from one function to another. Prototypes are also a way to achieve inheritance in JavaScript. I am wondering when it is best to use .inherits() versus changing the prototype chain. Any advi ...

Passing props to a wrapped component when utilizing a higher order component in React

While exploring the react documentation, I came across a section on Higher-Order Components that included an example of logging props for a specific component. function logProps(WrappedComponent) { return class extends React.Component { componentWillR ...

The query in the Mongo shell is not functioning as expected when used with mongoose

I have crafted a shell query that functions flawlessly when executed on mongo shell, but does not yield any results when run using mongoose in nodejs + typescript; Mongo shell db.userworks.aggregate([ { $match: { user: ObjectId("6 ...

How can one use jQuery to target elements that have names that are in an array format?

Is there a way to retrieve the values of these elements and send them as an array using ajax? <input type="checkbox" name="Broadcast[m]"/> Members <input type="checkbox" name="Broadcast[i]"/> IATA agencies <input type="checkbox" name="Bro ...

Styling CSS variables uniquely

I have limited knowledge of HTML and CSS, so I am unsure how to search for a similar post on StackOverflow. My apologies if this is a duplicate question. I am looking to achieve the following: margin-horizontal { margin-left: value; margin-right: va ...

Customizing the formatting of Angular's ui-select2 NoMatches message within a directive

I have a multiple select in a directive template and I want to customize the message that appears when no matches are found. The documentation on suggests overriding the formatNoMatches method for this purpose. This is the select element in my directive& ...

The toggle feature in jQuery doesn't hide content in the same manner as it was originally shown

Just diving into the world of jquery and I'm experimenting with the toggle function to display and hide a div, along with adding or removing an active class. http://jsfiddle.net/MAkyw/ I've encountered 2 issues: 1) The 'active' class ...

What is the best way to implement useState within a loop?

I'm currently working on a mini app that allows users to select multiple music albums using Next.js. My album display is similar to the image below, and I want to include a check mark when an album is clicked, and remove it when clicked again. Here& ...

The Bootstrap glyphicon content breaks when using ASP.NET MVC minification

When working with asp.net, I noticed that minification tends to disrupt the display of bootstrap UTF symbols. For example, here is what it looks like in the original file: .glyphicon-edit:before { content: "\e065"; } And here is how it appears in ...

Is there a specific explanation as to why ng-repeat-start is not functioning properly even with the most recent version of AngularJS?

Can someone please explain why ng-repeat-start is not functioning properly despite using the most up-to-date AngularJS version? I have included it from the CDN: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></scr ...

Saving information in binary format to a file

I have a script for setting up an installation. This specific script is designed to access a website where users can input values and upload a certificate for HTTPS. However, the outcome seems to be different from the expected input file. Below is the cod ...

Using Material UI DataGrid Pro to render cells with asynchronous data processing

Currently, I am utilizing Material UI's DataGrid Pro and have come across an issue with displaying a user's avatar image in a column. The challenge lies in asynchronously fetching the image while showing a skeleton URL placeholder during the load ...

Creating a simple form page using Express JS

I am a beginner in the world of Node Js and Express Js, currently diving into learning from a book titled "Jump Start NodeJs" by Sitepoint. The author has provided a simple Login Form page as an example in the book. However, when trying to implement the co ...

Navigational Drop-down Menu - Utilizing Next.js and Tailwind CSS

Currently, I'm tackling a project that requires me to implement a dropdown menu using tailwind CSS and Next.js. Would be incredibly thankful if someone could provide me with a sample code for this feature. ...

Leveraging Angular for REST API Calls with Ajax

app.controller('AjaxController', function ($scope,$http){ $http.get('mc/rest/candidate/pddninc/list',{ params: { callback:'JSON_CALLBACK' } }). success(function (data, status, headers, config){ if(ang ...

Issue with CSV download box not showing up on Rails version 2.3.11

I've encountered an issue while trying to export a csv file with some data. I am using ajax call to select rows from the view table (jqGrid) and export them in a csv format. However, after a successful ajax call, the filtered data is displaying as an ...

Adapting my JavaScript code to handle one-dimensional CSV data instead of the usual two-dimensional format

How can I effectively parse this CSV file using JavaScript? 1363085391,42.890000000000,5.432200000000 1363088879,47.570000000000,4.981800000000 1363120475,56.560000000000,1.768000000000 1363132522,53.000000000000,1.000000000000 1363214378,48.630000000000, ...

Distinguishing Between Angular and Ajax When Making Requests to a NodeJS Server

Trying to establish communication between an Angular client and a NodeJS server. Previous method using JQuery $.ajax({ url: "/list", type: "POST", contentType: "application/json", dataType: "json", success: function(data) { console.log("Data ...