ContextMenu & transform
See original GitHub issueHi fkhadra,
I got next problem: I have the parent element with style transform. When I add context menu on child element, then its behaviour incorrectly.
Please, find example below.
import React from 'react';
import { ContextMenu, Item, ContextMenuProvider } from 'react-contexify';
import './App.css';
import 'react-contexify/dist/ReactContexify.min.css'
export default class App extends React.Component<any, any> {
childrenShow: boolean;
constructor(props) {
super(props);
this.childrenShow = true;
this.handleMenuSelect = this.handleMenuSelect.bind(this);
this.handleMenuUnSelect = this.handleMenuUnSelect.bind(this);
this.handleMenuDelete = this.handleMenuDelete.bind(this);
}
render() {
if ( this.childrenShow ) {
return (
<div className="App" style={{marginTop: '200px', transform: 'translate(0)'}}>
<ContextMenuClass handleMenuSelect={this.handleMenuSelect} handleMenuUnSelect={this.handleMenuUnSelect} handleMenuDelete={this.handleMenuDelete} />
</div>
);
}
return (
<div className="App">
Hiden
</div>
);
}
handleMenuUnSelect() {
this.childrenShow = false;
console.log('unSelect triggered');
}
handleMenuSelect() {
this.childrenShow = false;
console.log('select triggered');
}
handleMenuDelete() {
this.childrenShow = false;
console.log('delete triggered');
this.forceUpdate();
}
}
export class ContextMenuClass extends React.Component<any, any> {
render() {
return (
<div>
<ContextMenuProvider id={'context_menu'}>
ContextMenu
</ContextMenuProvider>
<ContextMenu theme="dark" id={'context_menu'}>
<Item onClick={this.props.handleMenuUnSelect} disabled>Unselect</Item>
<Item onClick={this.props.handleMenuSelect} disabled={true}>select</Item>
<Item onClick={this.props.handleMenuDelete}>Delete</Item>
</ContextMenu>
</div>
)
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:39 (18 by maintainers)
Top Results From Across the Web
context menu position with transform - CodeSandbox
context menu position with transform. css transform will create new stacking context and will mess up with right click x and y when...
Read more >CSS transform: translate() on Parent Breaks Context Menu #147
Context menu appears next to cursor when right-clicking. Actual Behavior. Context menu shifted twice as much as the parent's transform away from ...
Read more >Is there a way to convert a Controls.ContextMenu to a Forms ...
No - the controls are for completely different platforms (Winforms vs WPF). There is no "conversion" between the two. Either use a different...
Read more >ContextMenu Class (System.Windows.Controls)
Gets or sets transform information that affects the rendering position of this element. This is a dependency property. (Inherited from UIElement).
Read more >Using ContextMenu and ContextMenuItem in Unity 3D
There are a lot of options available to you when you want to test your project in Unity3D and validate that your code...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I pushed the new version. You won’t get the “Did you forgot to bind an event” message.
@brezetsky regarding your snippet won’t work, only the parent menu will be displayed. To fix it move the
<ContextNestedMenuClass />
as follow:Sorry for the late release btw
I ran into the same issue here, can’t tell if it was resolved and regressed from the old discussion above or not, but I was able to fix it by throwing the
<Menu>
render inside a React Portal: