Ability to override Modal container inside Popover #11733
Labels
component: modal
This is the name of the generic UI component, not the React module!
component: Popover
The React component.
new feature
New feature or request
Milestone
Expected Behavior
Popover allows to render itself in a non-Modal container (e.g. Portal) to support non-background-blocking components and behaviours which still render outside of parent component's DOM tree.
Current Behavior
Popover always renders inside a Modal container, blocking the background.
Context
When upgrading to MUI 1.x, we had to reimplement a couple of more complex components we were using - things like
ChipInput
andAutoComplete
. Our use case is a bit more complex that what is shown in Autocomplete demo, as we render these components inside modal dialogs - and we ran into a problem when the rendered lists were getting cut off by dialog's boundaries.Popover
seems to provide the perfect way to solve this, with the only exception - it renders itself inside its own Modal, which blocks the background etc. But going lower level withPortal
also means that we need to reimplement the rest of the logic that exists in Popover (mostly things around its positioning), which seems like a waste. There's also no easy way to extend the component or pull out just the position logic for reuse - as Popover exports only itswithStyles
wrapper, and not the naked Popover component itself.For the current working solution we used a version of Popover which is literally a full copy of the component, with a single change - the line that render
Modal
component here got replaced withPortal
instead:This was the only change needed, and I'm wondering what would be MUI's preferred approach to support this in Popover itself? Is implementing a
component
prop (similar to how it for forListItem
etc) the way to go here? E.g.<Popover component="portal">
to have it use Portal instead.I'll be happy to take a shot at PR myself, just want to make sure this is the correct approach for a case like this. If this is implemented - it will also enable Dropdown-like functionality requested in #9893, and return the possibility to render non-modal popovers discussed in #8202.
The text was updated successfully, but these errors were encountered: