Tips for creating a Material UI (next) dialog with generous top and bottom margins that extend off the screen

I am encountering a challenge with the layout.

What am I looking for?

I need a modal dialog that expands vertically, extending beyond the screen, centered both horizontally and vertically, with minimal margin on the top and bottom.

Is this feature not documented in MUI? The prescribed method in MUI displays a dialog with scrollable content, keeping the action button constantly visible. However, this does not align with our app's design concept. While it may defy Material Design guidelines, it is necessary for our application.

Have you conducted a Google search on this issue? Yes

What have I achieved so far? I have managed to make the dialog grow beyond the screen, with background scrolling appropriately. Nevertheless, I am unable to maintain top and bottom margins as desired; it stretches until it hits the top at 0 (refer to screenshot 2).

To better illustrate this problem, I will showcase two significant scenarios: the dialog smaller than the viewport (A) and larger than the viewport (B).

Screenshot 1 - state A - ideal scenario https://i.sstatic.net/ceMIP.png

Screenshot 2 - state B upper functioning adequately without top / bottom margins https://i.sstatic.net/RITBM.png

Screenshot 3 - state B upper preferred https://i.sstatic.net/8PESM.png

Screenshot for state A highlighting the issue by adding top / marginTop / paddingTop https://i.sstatic.net/gwPkj.png

Explore this example here: https://codesandbox.io/s/lxw7ylxy8z

Thus, utilizing a marginTop or top property on the paper element of MUI, or a paddingTop within the root element of the MUI Component dialog property, disrupts state A’s vertical centering while failing to apply bottom margin in state B.

I am contemplating solutions like EQCSS or computations based on the dialog's computed size. Nevertheless, I believe there should be a more efficient approach using only CSS and flexbox. The challenge lies in inserting elements within the MUI Hierarchy, or perhaps I lack the knowledge on how to achieve this.

Hoping for assistance on this matter, Feel free to request additional information if needed.

Answer №1

Adding fixed height divs at the top and bottom made it a breeze to implement. Take a look at the demo here:

I'm going with this solution for the time being.

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

Safari-exclusive: Google Maps API dynamically altering page aesthetics post-loading

Recently, I encountered a peculiar problem. Upon loading a page, the text displayed with full opacity. However, upon the Google Maps API loading after 2 seconds, the entire page's styling suddenly changed. It was as if the text on the page became less ...

How can I implement a single-column search feature in a GridView using Javascript in ASP.NET?

I found a Google function for client-side searching in a grid using a textbox Here is the function: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> function searchFunction(phrase, ...

What is the best way to retrieve the object of the selected option from a single select input in Angular

I'm currently working with an array of objects that looks like this: let myArray = [{'id':1,'Name':"ABC"},{'id':2,'Name':"XYZ"}] I'm trying to retrieve object values based on a dropdown selection, but so ...

Unleashing the power of conditional exports in package.json

Within my package.json, I define an exports section: "exports": { "import": "./dist/a.es.js", "require": "./dist/b.umd.js" }, However, during development, I wish to use different pa ...

Tips for concealing an entire row of a table with Jquery

I am currently working on a system that involves a table with anchor tags named original and copy in each row. By clicking on these anchor tags, we are able to update the database whether the item is an original or a copy using ajax. However, I am facing a ...

Angular directive used to create a nested tree list

Currently struggling with a nested list Directive in Angular. Whenever I attempt to run the code, the browser crashes due to the recursive call of the directive. My goal is to display a new list item if the data's children property contains items. H ...

Trouble displaying static files in Angular/Express app on Heroku, while they are functioning as expected on local environment

After deploying to Heroku, I noticed that the css and javascript files in the 'public' directory were missing, resulting in 404 errors. Strangely, these files exist locally without any issues. In my app.js file, I have included the following: a ...

The Adonis 5 build failed to transfer the environment file to the designated build directory

During my experience with Adonis 5 in production, I consistently encountered an issue where the .env file failed to copy into the build folder when I attempted to run `npm run build`. Is this still considered a bug in the system? ...

Guide to sending data from an HTML page to a MVC Controller using WebApi

How can I fix the issue with my HTML button not calling the API properly? function saveclickdata() { var allData = { InvNo:document.getElementById('TbInvNo').value, GrossSale:document.getElementById('Tb ...

To clear the previous result of an AJAX call in JavaScript, reset the function or variable

I encountered a problem previously, and now another issue has come up. It appears that the previous result from my ajax JavaScript is still being displayed, and I need to prevent that from happening. I've tried deleting the variable, setting it to und ...

Sending the handleSubmit() function to the child component does not alter the state of the parent component

I just started learning React and Javascript. Currently, I am working on a form where users can specify the details of a "Mob". Upon submitting the form, I anticipate that handleSubmit() (which is passed down from the parent component) will update the sta ...

Implement a callback function for unchecked checkboxes on change

Currently, I am working with a gridview that includes a checkbox field. My goal is to use jQuery to create a function that activates when an unchecked checkbox is checked. function clickAllSize() { alert("helloy"); } $(document).ready(function () { ...

Retrieving the value of a child in JSON

I have encountered this JSON structure and I am interested in extracting the value of "resource_uri" which is "/api/v1/client/2/". My implementation revolves around Backbone/javascript. Unfortunately, using json['resource_uri'] does not produce ...

Enhancing specific child value in Firebase Database using JavaScript: Exploring Firebase Realtime capabilities

I have a database structure where I need to update the value of isseen to true when the sender is equal to "5". Here's an example of my database structure: Chats -LvuhnORi1ugp8U2Ajdq isseen: "false" message: "hi" receiver: "OX0pReHXfXUTq1XnOnTSX7moiG ...

An effective way to eliminate or verify duplicate dates within an array in AngularJS1 is by employing the push() and indexOf() methods

I have successfully pulled EPOCH dates and converted them into strings, but my previous code did not check or remove duplicates. Does anyone have any suggestions on what I can add to accomplish this? The timestamp in this case is the EPOCH date that I re ...

Convert an array into a query string parameter

Currently, I am refactoring some code and attempting to replace the generation of query strings through concatenation with serializing a JSON object. Original Code: $.ajax({ url:'./services/DataService/getDetails?metric=9&'+dashBoards.g ...

Is it possible to disable the "super must be called before accessing this keyword" rule in babelify?

My current setup involves using babelify 7.2.0 with Gulp, but I've encountered an error when working with the following code snippet: class One {} class Two extends One { constructor() { this.name = 'John'; } } The issue at hand i ...

I am looking to have the first option in the dropdown menu appear as a placeholder text

In my form, I have two phone number fields - one for mobile phone and the other for home phone. I need to make only one of them mandatory. Can someone please advise me on how to accomplish this? ...

What could be causing an issue with exporting the ListItem component in Material-UI?

Here is an example where I am attempting to export the ListItem component from Material-UI. import ListItem, { ListItemProps } from '@material-ui/core/ListItem'; export const MyListItem = (props: ListItemProps) => ( <ListItem {...prop ...

Using Typescript and webpack to detect variables that are defined in the browser but not in Node environment

My goal is to create a package that can be used on both servers and clients with minimal modifications required. Some libraries are available in Node but not in a browser, while others are accessible in a browser but not in Node. For instance, when utili ...