Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form in dialog breaks content scrolling separately from actions #12126

Closed
2 tasks done
Philipp91 opened this issue Jul 12, 2018 · 4 comments
Closed
2 tasks done

Form in dialog breaks content scrolling separately from actions #12126

Philipp91 opened this issue Jul 12, 2018 · 4 comments
Labels
component: dialog This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@Philipp91
Copy link
Contributor

  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Context

In #6128, the use case of having a

inside a was described. @oliviertassinari referred to 1.x and dialog composition for this. Now we have 1.x and it mostly works. I'm using code very similar to the one that @oliviertassinari posted (adjusted to match new prop names):

<Dialog open={true} onRequestClose={() => {}}>
  <DialogTitle>{"Use Google's location service?"}</DialogTitle>
  <form onSubmit={this.handleSubmit}> 
    <DialogContent>
      <TextField placeholder="Name Surname" fullWidth={true} />
    </DialogContent>
    <DialogActions>
      <Button onClick={this.handleRequestClose}>Disagree</Button>
      <Button onClick={this.handleRequestClose}>Agree</Button>
    </DialogActions>
  </form>
</Dialog>

The only real difference is that my content is a longer form, which may be higher than the viewport.

Expected Behavior

The always remains at the top of the dialog, the always remain at the bottom of the dialog and only the scrolls.

Current Behavior

The entire scrolls, including title and action.

Steps to Reproduce

https://codesandbox.io/s/n70k9mmwvm

Use the code above. Make the window really small until the scroll bar appears.
Remove the and it works (Because the form content is rather small, there's only a brief period where the scrolls, then it hits 0 height and everything has to start scrolling.)

Tech Version
Material-UI v1.3.1
React v16.4.1
browser Latest Chrome
@Philipp91
Copy link
Contributor Author

And there's another (probably related) problem that can also be seen from the same codesandbox.io example above: The should get paddingTop: 0, but it doesn't when it's inside the

, so there's a large weird-looking gap between the title and the text field.

@oliviertassinari oliviertassinari added support: question Community support but can be turned into an improvement component: dialog This is the name of the generic UI component, not the React module! labels Jul 12, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 12, 2018

@Philipp91 This should do it:

  <Dialog open={true} onRequestClose={() => {}} style={{ maxHeight: 250 }}>
    <DialogTitle>{"Use Google's location service?"}</DialogTitle>
    <form
      style={{
        display: "flex",
        flexDirection: "column"
      }}
    >
      <DialogContent>
        <TextField placeholder="Name Surname" fullWidth={true} />
      </DialogContent>
      <DialogActions>
        <Button>Disagree</Button>
        <Button type="submit">Agree</Button>
      </DialogActions>
    </form>
  </Dialog>

https://codesandbox.io/s/2zqow476w0

@Philipp91
Copy link
Contributor Author

Thanks!

@Philipp91
Copy link
Contributor Author

And <DialogContent style={{paddingTop: 0}}> to fix the spacing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants