-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
renderBodyContextMenu gets rendered outside of React root #1121
Comments
seems like the crux of this issue is using |
thanks! |
Does this require work on blueprint's side? Sorry I'm unclear |
Any update on this? |
no, I don't think anyone has looked into this. would be open to PRs (with tests included). I believe this is the line in question that @giladgray is referring to:
|
ugh this is not easily fixable. i'm not sure that using |
@giladgray The root cause of these issues seems to be that the What do you think about re-implementing the
I know that you are currently working on a fix for Attached a partial implementation. contextMenu.tsx import { Portal } from "../portal/portal";
// ...
export interface IContextMenuProps {
// Move fields in state to props so that the fields can be passed by ContextMenuTarget components
menu?: JSX.Element;
offset?: IOffset;
// ...
}
// ...
export class ContextMenu extends AbstractPureComponent<IContextMenuProps, IContextMenuState> {
// ...
public render() {
const content = <div onContextMenu={this.cancelContextMenu}>{this.props.menu}</div>;
// ...
return (
// Wrapping with Portal
<Portal>
<div className={Classes.CONTEXT_MENU_POPOVER_TARGET} style={this.props.offset}>
<Popover
// ...
</Popover>
</div>
</Portal>
);
}
// ... contextMenuarget.tsx import { ContextMenu } from "./contextMenu";
// ...
public render() {
// ...
const onContextMenu = (e: React.MouseEvent<HTMLElement>) => {
e.persist();
e.preventDefault();
this.setState({ e } as any);
};
const menu = this.state.e ? this.renderContextMenu(this.state.e) : null;
const root = React.cloneElement(element, { onContextMenu });
return (
<React.Fragment>
{root}
{menu && (
<ContextMenu menu={menu} offset={{ left: this.state.e.clientX, top: this.state.e.clientY }} />
)}
</React.Fragment>
);
}
}
// ... |
@js-um @giladgray Would be great to get the menu re-rendering when state/props changes. |
for
blueprintjs/table
Bug report
blueprintjs/table
: 1.14.0Steps to reproduce
Create a table with
renderBodyContextMenu
. View the context menu in the React dev console and see that its react context is emptyActual behavior
renderBodyContextMenu
gets rendered outside of the React hierarchy that theTable
is in so the context menu does not have access to my React contextExpected behavior
context menu has React context
The text was updated successfully, but these errors were encountered: