<Popover /> anywhere with usePortal={true} (default behaviour)bp3-popover-open class still appears on the targetusePortal prop to true gets rid of the bug.Still not resolved, but we have found that by setting portalContainer={document.body} (the default) portals render correctly.
@mulholio i have never heard of this issue. my gut says it's something weird with your environment. can you please attempt to create a repro on codesandbox? https://codesandbox.io/s/rypm429574
Thanks for the link. I have tried copying problematic code from two different parts of our app and haven't succeeded in reproducing the bug in Codesandbox. Given this, I suspect your analysis is correct and our environment is doing something strange.
Closing the issue, but was wondering if you had any ideas on what the cause might be?
I have the exact same behaviour as you @mulholio
Have you figured out what was wrong in your environment, and how to fix it?
Regards
Niklas
@nikko242 no resolution yet. I'm just relying upon the usePortal prop for now as a work around. Give us a shout if you find a better fix!
Ok, thanks.
No, we also use usePortal together with portalContainer to make it work.
I have had a look at the code, and it seems strange to me that it could work on a different environment, it seems that portalContainer never gets set to "document.body" as default as stated in the documentation.
@nikko242 Any luck on this? Was hoping to resolve the issue just with usePortal={false} but the Overlay component is used behind the scenes on other Blueprint Components (e.g. Table Cell Context Menus) so we're running into still.
We've deleted all the CSS so it doesn't appear to be anything related to that.
I can find the underlying Portal and children in React dev-tools but mousing over just shows 0px x 0px at the top left and doesn't actually render the content on the page.
Further investigations:
<Portal /> render method the portal is only created if this condition is false:state.hasMounted is false. This is because props.container is null (see componendDidMount() for this)Still trying to work out why the container prop is missing.
We work around this, by manually settings portalContainer when Portal=true, it works .. but the code gets abit bloated:
<Dialog
onClose={this.props.OnClose}
title="脛ndra skipass"
isOpen={true}
usePortal={true}
portalContainer={document.body}>...
</Dialog>
I have taken a look in the blueprinjs source code, and I think It would be quite easy to fix:
In "packages/core/src/components/overlay/overlay.tsx"
line: 231
<Portal className={this.props.portalClassName} container={this.props.portalContainer}>
Change to:
<Portal className={this.props.portalClassName} container={this.props.portalContainer != null?this.props.portalContainer:document.body}>
Would the Blueprint team be open to adding this to the Overlay component?
After:
<Portal
className={this.props.portalClassName}
container={this.props.portalContainer ? this.props.portalContainer : document.body}
>
At the very least, I feel like there should be some kind of error thrown if you try and create a portal with no container element referenced. As suggested by @nikko242 , document.body seems like a sensible default to create a portal on if none is explictly passed?
Happy to make a PR.
@mulholio that default gets set further down the component stack: https://github.com/palantir/blueprint/blob/3dcbb0113f7f58637dec57a85c445011d51bafb6/packages/core/src/components/portal/portal.tsx#L59. so I don't think your suggested change would fix this.
but I will admit it's confusing for Overlay's docs to list @default document.body for its portalContainer prop when it doesn't actually do any default handling itself (only Portal does that).
I'm also encountering this issue. Setting document.body explicitly seems to resolve. If it helps, things break for me starting with 3.8.0. They work in 3.7.0. I'm therefore fairly certain the problem was introduced by #3045.
If you are still seeing this issue can you create a repro of it in a code sandbox (see link in the README or issue template) or a small repo?
This is still an issue for me. Trying to see what I can do to simplify my own configuration and pinpoint the issue. Thus far, my best guess is that it somehow has something to do with Rails + Webpacker + Blueprint... I'm unable to get even a simple example (page literally just displays a Popover Button, all other JS/TS/CSS/SCSS code has been removed, and all unnecessary packages have been removed) to work with this pipeline using the latest versions of everything.
Setting document.body explicitly still works, but I'm out of luck without that (and not all of the popover components expose the portalContainer prop, particularly the DateInput and the like, I think).
Any chance anyone else with this issue is using a similar setup? May try to see if I can create a fresh small repo with this, if for no other reason than to test my own sanity...
Here's the smallest possible Rails + Webpack + Blueprint repo I could create. To my chagrin, still seeing the issue here. I've done the absolute minimum of additional configuration outside of the defaults. Would love to hear that the Rails defaults just misconfigure Babel or Webpack somehow... or that I did something super dumb and unexpected.
Since Code Sandbox doesn't support this sort of environment, I can't replicate this there. I'm not able to reproduce my issue with Code Sandbox's pre-built envs.
Hi, i've encountered same issue with my own setup. Usually, bundle injected in end of body, and div#root is present in layout.
But in my setup, I've injected bundle to head, and wrap my React.render with DOMContentLoaded.
It's hard to reproduce on codesandbox, because of custom webpack-html-plugin options
When I reverted setup to "defaults", problem is gone.
Hope this would be helpful
@chiubaka we were getting this issue on a Rails app too so sounds like you might be onto something. I've left the project recently but @strickland84 may have some relevant details.
Ah... well, that's interesting. So actually including <%= javascript_pack_tag "application" %> in the HTML head causes document.body to be initially null when all the scripts run. I think this is causing Blueprint some headache... likely there's some initialization code for the Portal that doesn't like this.
Moving <%= javascript_pack_tag "application" %> to the bottom of the body seems to solve the issue.
Generally it's best practice to inject application scripts at the bottom of body anyway, so as to not block HTML rendering.