https://codesandbox.io/s/practical-kalam-jz2ew?file=/src/Demo.js
open the popper by clicking on the button
popperRef to update the position of the positioning or start using the resize observer https://github.com/mui-org/material-ui/issues/9337#issuecomment-413789329For #1 you can add the following popperOptions to the Popper component:
popperOptions={{
positionFixed: true,
}}
and this should fix this problem (https://codesandbox.io/s/practical-kalam-jz2ew?file=/src/Demo.js:2167-2232)
For #3 you could also just let the parent Popper component know when it's Child component updates using a callback function - https://codesandbox.io/s/loving-water-b9950?file=/src/Demo.js. You could also just nest the Child component in the Popper component too. Not sure if that would be more efficient than using a Ref but it might be easier.
@mlizchap Thank you for the suggestions. While the first one is really helpful (and should probably be included in the docs) using the second one feels a bit weird - For example I would not expect that I have to pass an update to a Card when it's child is changing. Also in my case it's a bit harder as I deal with a form which updates in multiple occasions not just on a button click.
@oliviertassinari regarding 2. what do you mean by definition? inside the docs it says: "Always keep the children in the DOM." - I would expect that the popper gets hidden simply but not that it adds whitespace at the bottom of the page.. Is there any way to prevent it?
To clarify the "improvement" I have in mind behind the label: look into using ResizeObserver to avoid having to manually get a ref on popper and update the position as we used to do in the Slider demo or Rating demo.
Thank you for clarification. Wrapping the inner of the popper with
<Box display={open ? "block" : "none"}></Box>
as demonstrated here: https://codesandbox.io/s/nervous-cloud-s2x4p?file=/src/Demo.js:2264-2316 does the job
Most helpful comment
For #1 you can add the following
popperOptionsto thePoppercomponent:and this should fix this problem (https://codesandbox.io/s/practical-kalam-jz2ew?file=/src/Demo.js:2167-2232)