Skip to content

[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

Merged
merged 1 commit into from
Jun 30, 2023
Merged

Conversation

arielj
Copy link
Collaborator

@arielj arielj commented Jun 24, 2023

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 the dialog 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:

  • the settings as a normal page
  • in game settings in a dialog
  • in the installation information time information etc links in the game page
  • the accessibility page

I 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:
image


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

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@arielj arielj added the pr:ready-for-review Feature-complete, ready for the grind! :P label Jun 24, 2023
@arielj arielj requested review from a team, flavioislima, CommandMC, Nocccer and imLinguin and removed request for a team June 24, 2023 04:24
max-width: 500px;
overflow-y: auto;
overflow-x: hidden;
position: absolute;
Copy link
Collaborator Author

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)) {
Copy link
Collaborator Author

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 () => {
Copy link
Collaborator Author

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

@arielj arielj requested a review from redromnon June 24, 2023 04:32
@redromnon redromnon linked an issue Jun 24, 2023 that may be closed by this pull request
Copy link
Collaborator

@redromnon redromnon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me 👍

@flavioislima flavioislima merged commit f7c35d3 into main Jun 30, 2023
@flavioislima flavioislima deleted the fix-popover-dialog branch June 30, 2023 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help Icon Infobox not working in Game Setting Modal
3 participants