The presence of the StickyHeader Row is causing an obstruction in the drop down list view

I have successfully made the row header of the Material UI Table component sticky by utilizing the stickyHeader attribute.

<Table stickyHeader className={classes.table}></Table>

Above this table, there are two drop-downs that are created using the ReactSelect component.

const DropDown = props => (
    <div className={[props.divClasses, props.error ? 'error-class' : ''].join(' ')}>
        <ReactSelect
            {...props}
            classNamePrefix="normal-select"
            disabled={props.disabled ? props.disabled : false}
            multi={props.multi}
            placeholder={props.placeholder ? props.placeholder : 'Select'}
            closeOnSelect={props.closeOnSelect}
            clearable={props.clearable}
            searchable={props.searchable}
            options={props.options ? props.options : []}
            value={props.simpleValue ? props.options.filter(
                ({ value }) => value === props.value) : props.value}
            isLoading={props.isLoading}
            className={` ${props.className ? props.className : ''}`}
            onChange={option => props.onChange(props.property, props.simpleValue ? option?.value : option)}
            onBlur={props.onBlur}/>
        {props.error && <FormHelperText style={{ color: '#f44336' }}>{props.error}</FormHelperText>}
    </div>
);

However, due to the sticky nature of the table header, it is causing some display issues with the drop-downs.

Currently, the view looks like this: https://i.sstatic.net/v3Zy5.png

The expected behavior should resemble this: https://i.sstatic.net/xp1dg.png

I would appreciate any assistance in resolving this matter.

Answer №1

The overlapping occurs because the default z-index value of mui table's sticky header is set to 2, which is higher than the default z-index value of the react-select menu, set to 1.

To resolve this issue, you can increase the z-index of the menu property in the react-select component to a value greater than 2 using custom styles:

const customStyles = {
    menu: (provided, state) => ({
      ...provided,
      zIndex: 3
    })
};


<ReactSelect
  value={selectedOption}
  onChange={setSelectedOption}
  options={options}
  styles={customStyles}
/>

For a live example demonstrating this solution, check out this sandbox.

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

What is the best way to utilize data obtained from a POST request in order to carry out a subsequent

I'm currently working on a project that involves integrating the Spotify API into a web application. The goal is to take a user-submitted search keyword, send it to the server for processing, and then receive and display the search results on the fron ...

How can I show or hide all child elements of a DOM node using JavaScript?

Assume I have a situation where the HTML below is present and I aim to dynamically conceal all the descendants of the 'overlay' div <div id="overlay" class="foo"> <h2 class="title">title</h2> ...

What steps should I take to resolve the "sass" module not found error?

As someone new to React, I decided to take a different approach in starting my project instead of using create-react-app. I ended up using createapp.dev which utilizes a parcel bundler instead of the usual react-scripts bundler. However, when I tried dep ...

Tips for implementing a toggle feature for an ion-card element

I am looking to create a toggle effect on ion-card, where clicking on the card will highlight it until either unclicked or another card is clicked. Similar to this - https://i.sstatic.net/MH5WA.png How can I achieve this effect on ion-card? Here is my H ...

What is the method for achieving the equivalent effect of "background-size: cover" on an <img>?

I am looking to ensure that an <img> has the smallest possible size without any empty spaces inside a div, while also being perfectly centered both horizontally and vertically. The image size may vary. To better illustrate, here is an example: http: ...

The Netlify build encountered an error: Command resulted in exit code 1 - To learn more about this issue, visit https://ntl.fyi/exit-code-1

Trying to deploy my portfolio on Netlify for the first time has been a learning experience. After researching and attempting to add "CI = npm run build" to build settings as recommended in various articles, I encountered an error that prevented successful ...

I am interested in creating a table that can toggle between show/hide mode with a plus/minus feature

$(document).ready(function() { $("#t1").hide(); // hide table by default $("#close").hide(); //hide the minus button as well if you only want one button to display at a time $('#sp1').on('click', function() { //when p ...

javascript various backgrounds on click

I have implemented a list to allow users to select their top 3 choices, and I am using JavaScript to track these selections and change the background color accordingly. 1st selection -> Green background 2nd selection -> Yellow background 3rd sel ...

Troubleshooting a problem with placeholder styling on Internet Explorer

Encountering a challenge while styling placeholders, particularly in Internet Explorer where the placeholder text color does not change as expected. Instead, it inherits the color of the input field. :-ms-input-placeholder { color: white; } input ...

Can a local HTML page be embedded within another?

Suppose I have two HTML pages: index.html and embed.html. Within embed.html, there is an arbitrary HTML page that I want to embed inside index.html. I attempted the following: <!DOCTYPE html> <html lang="en"> <head> <me ...

Ways to utilize a single HTML page for various URLs while changing one variable value based on the queried URL

My current HTML page structure looks like this: <body ng-controller="DashboardDisplay" onload="submit()"> <div class="container-fluid" > {{scope.arr}} </div> </body> <script> var myApp = angular.module(&apos ...

The CSS 'top' attribute is without impact

As I begin my journey with CSS, I am eager to grasp some of its behaviors. In the CSS file, the following code is defined: #spa { position : absolute; top : 8px; left : 8px; bottom : 8px; right : 8px; min-height : 500px; min-width : 500px ...

Tips on rearranging the location of a div element within a directive

I have created a custom directive that displays two divs, Div1 and Div2, with a splitter in the middle: Splitter Image Now, I am looking for a way to swap the positions of these two divs dynamically using an Angular directive. I thought about using ng-swi ...

How can I update the state with the value of a grouped TextField in React?

Currently working on a website using React, I have created a component with grouped Textfields. However, I am facing difficulty in setting the value of these Textfields to the state object. The required format for the state should be: state:{products:[{},{ ...

Enhance your slideshows with React-slick: Integrate captivating animations

I recently built a slider using react slick, and now there is a need to adjust the transition and animation of slides when the previous and next buttons are clicked. I received some advice to add a class to the currently active slide while changing slide ...

CSS can be utilized to craft intricate and dynamic shapes

Currently, I am attempting to produce a trapeze-like design utilizing various techniques in order to achieve the best possible outcome. The shape I am aiming to create is similar to this: (the content inside the shape will consist of images and text) Th ...

Maintain hover effect of main menu on sub-menu in CSS3 flip dropdown menu

Check out the fiddle I created for my query https://jsfiddle.net/e7te8hf1/ <section id="action-bar"> <div id="logo"> <a href="#"><img src="img/logo.png"></a> </div><!-- end logo --> <nav class="navbar navigat ...

Encountering difficulty importing the global.css file into the root layout of Next.js 13

Hello everyone, I'm completely new to Next.js version 13. Recently, I started a project with Next.js 13 and have been exploring the new app directory. My current challenge is applying styles using Tailwind CSS. I've been following the instructi ...

Is there a flaw in how Firefox handles text-overflow and inline-block?

It seems that according to the text-overflow specification, the ellipsis effect only applies to inline elements: This property defines how content within an inline element is displayed when it overflows its container's boundaries in the inline dire ...

Issue in Ionic 3 where ion-list does not scroll vertically on iOS devices when ion-items are dynamically generated using ngFor within the ion-list

When using Ionic v3 to develop a hybrid app, I encountered an issue where ion-items within an ion-list generated using *ngFor are not scrollable on iOS devices. Strangely, this problem does not occur on Android devices. Here is the HTML code snippet: < ...