-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Popper] anchorEl as fake DOM element #12211
Comments
@dispix I don't understand, why using the Popover or the Popper component for this use case? Why don't you use a combination of Portal + Grow + Paper? |
My understanding is that either the popper (or the popover) was adapted for that use case. If I misunderstood the way they were designed then maybe this feature request doesn't make much sense. |
@dispix The Popper & Popover positioning strategy works well with a reference element. When people already have the absolute position, it's much easier. However, you should be able to get along with it like this: <Popper
transition
onClick={this.reset}
open={open}
placement="bottom-start"
anchorEl={{
clientWidth: selection.boundingClientRect.width,
clientHeight: selection.boundingClientRect.height,
getBoundingClientRect: () => selection.boundingClientRect
}}
>
{({ TransitionProps }: any) => (
<Fade {...TransitionProps} timeout={{ enter: 350, exit: 0 }}>
<Paper>{renderContent(this.state.selection, this.reset)}</Paper>
</Fade>
)}
</Popper> https://codesandbox.io/s/r2vqkypoq (sorry for the TypeScrip errors) This use case is pretty close to #1462. I think that we could add a demo about it. The TypeScript definition of
|
@dispix Does that help? Going forward, I think that we should be:
Do you want to work on it? :) |
Yes that actually helps a lot ! The bindings between the |
Expected Behavior
@material-ui/core/Popper
should be positionable, similar to the popover which usesanchorPosition
.Current Behavior
The only available positioning is through
placement
, which makes impossible to place the popover inside the anchor element.Examples
My use case is for an element that pops up when the user selects some text. It is doable at the moment with the popover element by manipulating a couple of props and styles to remove the background (which was unnecessary, disturbing even in this case).
So right now, using the popover element is doable but requires a little bit of hack to get me where I want to go. Without the "hack", the backdrop inherited by the modal component will block any user interaction with the rest of the page. A simpler solution in my opinion would be to allow the popper element to be placed relative to the page and/or anchor element.
Demo : https://codesandbox.io/s/ppww439wzm (the popover works, the popper doesn't since it cannot be placed inside the anchor element).
Context
See the example. My need was to create a popover element under a text selection.
The text was updated successfully, but these errors were encountered: