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

Popover getPositioningStyle doesn't respect anchorEl's parent window #10037

Closed
1 task done
ianschmitz opened this issue Jan 25, 2018 · 0 comments
Closed
1 task done
Labels
bug 🐛 Something doesn't work component: Popover The React component.
Milestone

Comments

@ianschmitz
Copy link
Contributor

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

The Popover doesn't overflow the anchorEl parent window when being positioned.

Current Behavior

Popover.getPositioningStyle contains logic to position the popover relative to the anchorEl prop. It currently uses the global window object to get the innerHeight and innerWidth when calculating if the Popover is overflowing the window:
https://github.com/mui-org/material-ui/blob/c3afd7bb33fa26e465dc333449e9449a4bb9e7bd/src/Popover/Popover.js#L123-L125

The problem above is that it is referencing the global window object when performing its position calculations, instead of the parent window of the anchorEl prop. A quick fix for this could be to use Node.ownerDocument.defaultView if an anchorEl was provided, which returns the Window object.

Steps to Reproduce (for bugs)

See https://codesandbox.io/s/6lqo45vzvk. You can see that the menu is positioned correctly within the main window relative to the button, however in the popout window the menu overflows the parent window.

Context

After testing the rewrite of the Portal component following my previous issue #9207, I noticed the Popover positioning issue within the second window.

Your Environment

Tech Version
Material-UI 1.0.0-beta.30
React 16
browser all
etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: Popover The React component.
Projects
None yet
Development

No branches or pull requests

2 participants