question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Dialog] Form + scroll in DialogContent

See original GitHub issue
  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

I know this has been discussed in #12126, but there is still an issue with the scrolling, the title and the actions aren’t fixed and they scroll

Here is the codesandbox: https://codesandbox.io/s/qlo16r5v59

Here is the code

<Dialog open aria-labelledby="form-dialog-title">
  <form
    onSubmit={e => {
      alert("form submit!");
      e.preventDefault();
    }}
  >
    <DialogTitle id="form-dialog-title">Log in</DialogTitle>
    <DialogContent>
      <DialogContentText>
        Please enter your account number and password.
      </DialogContentText>
      <TextField
        autoFocus
        margin="dense"
        label="Account Number"
        type="text"
        fullWidth
      />
      <TextField
        margin="dense"
        label="Password"
        type="password"
        fullWidth
      />
      <div style={{ height: 1000 }} />
    </DialogContent>
    <DialogActions>
      <Button onClick={() => alert("cancel")} color="primary">
        Cancel
      </Button>
      <Button
        type="submit"
        onClick={() => alert("login")}
        color="primary"
        variant="contained"
      >
        Log in
      </Button>
    </DialogActions>
  </form>
</Dialog>

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

11reactions
oliviertassinaricommented, Jul 17, 2019

@hayatae Interesting, you need to apply this CSS

      <Dialog>
        <form
          onSubmit={e => {
            alert("form submit!");
            e.preventDefault();
          }}
          style={{
            overflowY: "auto",
            display: "flex",
            flexDirection: "column"
          }}
        >
          <DialogTitle

on the <form> element if you want to the dialog content to scroll instead of the dialog paper.

Alternatively, you can make the paper to host your form:

      <Dialog
        PaperProps={{
          component: "form",
          onSubmit: e => {
            alert("form submit!");
            e.preventDefault();
          }
        }}
      >
        <DialogTitle
6reactions
Ethorsencommented, Oct 23, 2018

+1 We face the same issue. I will implement that ugly fix for now.

But it would be nice to fix MUI at the source and allow <Dialog*> elements to be wrapped in a form without affecting layout/scrolling functionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mui/material-ui - [Dialog] Form + scroll in DialogContent - GitHub
This allows the inner flex element of Dialog to still be the operator of the flex-box container rules, and allows the children DialogTitle...
Read more >
Simple Material UI dialog example has unwanted scrollbar
UPDATE: DialogContent seems to be the culprit here, we can simply try replacing <DialogContent/> with a <div/> given below
Read more >
Scrolling dialog content | React Material-UI Cookbook
It can be hard to find enough vertical space to fit all of your content into a dialog. When the dialog runs out...
Read more >
Dialog with header, scrollable content and actions - StackBlitz
can be found in the LICENSE file at http:/ /angular.io/license -->.
Read more >
React Dialog component - Material UI - MUI
Form dialogs allow users to fill out form fields within a dialog. ... scroll=paper the content of the dialog scrolls within the paper...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found