Using Material-UI with React to solve the issue of DatePicker being hidden under modal

The MUI Parent Component includes a Page, followed by a modal also from MUI. Inside the modal, I am rendering the DatePicker component.

// @mui
import { DatePicker } from '@mui/x-date-pickers';

This is how it appears on the screen.

    <Controller
        name="createDate"
        control={control}
        render={({ field, fieldState: { error } }) => (
          <DatePicker
            label="Date create"
            value={field.value}
            onChange={(newValue) => {
              field.onChange(newValue);
            }}
            renderInput={(params) => <TextField {...params} fullWidth error={!!error} helperText={error?.message} />}
          />
        )}
      />

The issue arises when the DatePicker ends up displaying beneath the modal. How can this be resolved?

I attempted to follow the solution provided in this question, but it did not resolve the problem. It seems that those solutions are not applicable to the MUI DatePicker. Any assistance in addressing this would be greatly appreciated. Thank you.

Answer №1

Adjust the zIndex property of the modal component by changing

<Modal sx={{zIndex: 3}} ... >

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

Synchronization issue between Material UI SelectField component and state is observed in React/Redux setup

My issue involves the LayoutSelector component which contains a drop-down form that updates the state.plate.layout. The state is passed as a prop to the component. On my local machine, the selected menu item accurately reflects the state changes - when a n ...

Both paragraphs are on the same line

.footer { position: fixed; left: 0; bottom: 0; width: 100%; background-color: #3498DB; color: white; text-align: cent ...

After calling Subject.next, the function will return an Observable

In my current Ionic 2 project, I am focusing on implementing two key functionalities - logging out the user and remotely clearing the database. Below is the code snippet I have been working on: private logoutEvent: Subject<any> = new Subject(); priv ...

What is the process for transferring an image from a cloud function request to the vision API?

Just set up a Google Cloud Function with an HTTP endpoint. I want to pass an image to this endpoint and have it sent all the way to the Vision API (which is already set up) and then receive the response back. So, in essence: image in POST request -> C ...

Installing npm will overwrite the existing package-lock.json file, causing issues with the Modal functionality

Something strange is happening with package-lock.json. After deleting both node_modules and package-lock.json, then rebuilding them, my application functions correctly. However, when I run npm install again with only the newly built package-lock.json in pl ...

Retrieve and display the number of items in the shopping cart directly from localStorage using React

Utilizing react along with globalContext to populate a cart page by adding items that are then stored in an array within localStorage results in the following data structure being created: 0: {id: "9", title: "Apple Watch SE 40mm (GPS) - Spa ...

As the width decreases in animation, the content gradually disappears until it reaches zero

My issue involves red and black divs; when I hover over the parent element, the red div should appear by expanding to its full width. However, a problem arises when the width is set to 0px as the content still shows. Can someone provide assistance on how t ...

Limiting the style of an input element

How can I mask the input field within an <input type="text" /> tag to restrict the user to a specific format of [].[], with any number of characters allowed between the brackets? For example: "[Analysis].[Analysis]" or another instance: "[Analysi ...

How can I achieve a partial match for an object property in a JavaScript loop

How can I reformat this array of objects const arr = [{ my_first_name_1: { value: 'jane' }, my_last_name_1: { value: 'anderson' } }, { my_first_name_2: { value: 'alex' }, my_last_name_2: { value ...

The express-validator library raises errors for fields that contain valid data

I've implemented the express-validator library for validating user input in a TypeScript API. Here's my validation chain: export const userValidator = [ body("email").isEmpty().withMessage("email is required"), body(&quo ...

PhpStorm flawlessly detects ES7 type hinting errors

For my project, I have implemented TypeScript. While JavaScript's array includes() function has been valid since ECMA6, setting the lib parameter in tsconfig to "es6" results in a non-fatal error being thrown in the browser console when using the foll ...

Stop the sudden jump when following a hashed link using jQuery

Below is the code snippet I am working with: $( document ).ready(function() { $( '.prevent-default' ).click(function( event ) { event.preventDefault(); }); }); To prevent the window from jumping when a hashed anchor ...

Callback function for asynchronous operations on the client side with Meteor

Is there a way to retrieve the value returned by an asynchronous callback in the client-side of Meteor before the stack continues executing? Here is code snippet as an example: var result=function(str){ Meteor.call("getSearch",str,function(err,res){ ...

Ensure that the callback response in the $.ajax() function is treated as JSON dataType

My code snippet: <script> $('#email').on('blur', function(){ email = $(tihs).val(); $.ajax({ type: "POST", url: "ajax.php", data: { 'email': email, ...

Tips for verifying the functionality of this component---Is there anything

Assistance is needed to test this component using the expect library with karma and mocha. import React from 'react'; import {Clock} from 'Clock'; import {CountdownForm} from "CountdownForm"; import {Controls} from "Controls"; export ...

Make the Angular Modal scrollable except for when a specific div is being click dragged

I am working on an Ionic app that uses AngularJS. One issue I encountered is with a modal popup that can sometimes extend beyond the visible area. To address this, we applied overflow: hidden to its CSS class. However, there is a specific functionality i ...

Enhancing middleware chaining in Express

Below is the code for my Express configuration: var server = express() .use(express.cookieParser()) .use(express.session({secret: buffer.toString('hex')})) .use(express.bodyParser()) .use(express.static('./../')); serv ...

Is it possible to adjust the dimensions of the number input spinner?

When working with a number input that includes a spinner, I have encountered challenges in changing the size of the spinner itself. Specifically, I am referring to the <input type='number'> element. Despite my efforts to adjust its size thr ...

Tips on how to connect a single reducer function to trigger another dispatch action

In my React project, I'm utilizing a Redux-Toolkit (RTK) state slice that is being persisted with localStorage through the use of the redux-persist library. This is a simplified version of how it looks: const initLocations = [] const locationsPersist ...

utilizing object methods to retrieve object attributes

I am currently working on developing a new application named myApp. This application includes a property called regularNameErrors and a method called populateJSON. The populateJSON method utilizes an AJAX call to retrieve a JSON object, which is then added ...