-
-
Notifications
You must be signed in to change notification settings - Fork 480
[Bug] Fix popover inside settings dialog #2822
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
Conversation
max-width: 500px; | ||
overflow-y: auto; | ||
overflow-x: hidden; | ||
position: absolute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only adding these last 2 props and the relative for the parent
} | ||
// add a click listener to close the popover when clicking outside | ||
const callback = (event: MouseEvent) => { | ||
if (!wrapper.current!.contains(event.target as HTMLElement)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if clicked outside the wrapper, close the popover
const handleClose = () => { | ||
setAnchorEl(null) | ||
} | ||
return () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the popover is closed, remove the listener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me 👍
This PR fixes an issue where the popover component was not visible when used inside a modal.
Because of how the MaterialUI
Popover
component works, it was added to the document body, and it was always behind thedialog
element and it was impossible to bring it to the front.I tried many options of the Popover component to put it inside the dialog which partially fixed this but then the positioning was broken.
At the end I decided to go with a simpler solution implementing a similar functionality to have more control and to avoid all the weird things the MUI component was doing (adding styles, extra elements, scrolling the container, etc).
I tried this in:
installation information
time information
etc links in the game pageI think I covered all the places but please let me know if something looks wrong.
An example of this working where it was not working before:

Use the following Checklist if you have changed something on the Backend or Frontend: