Context menu open(x,y) is actually open(y,x)

Hi

In the docs I saw the following:
https://ej2.syncfusion.com/react/documentation/context-menu/how-to/open-and-close-contextmenu/

I want to open the context menu near a specific component/ref, but when trying it, I noticed that x,y are actually y,x
menuRef.current.open(searchRef.current.getBoundingClientRect().y + searchRef.current.getBoundingClientRect().height+3, searchRef.current.getBoundingClientRect().x);

Either the docs should be corrected or open implementation should be fixed.

3 Replies

AS Aravinthan Seetharaman Syncfusion Team April 23, 2021 05:15 PM UTC

Thanks for contacting Syncfusion Support. 
We have checked your query. We cannot reproduce your reported issue in our end. However we suspect thar you are giving incorrect parameter order. We need to give parameter in open(top,left) order. Please refer the below code snippet and sample. 
 
 
class App extends React.Component { 
  constructor(props) { 
    super(props); 
    this.menuItems = [ 
      { 
        text: "Cut" 
      }, 
      { 
        text: "Copy" 
      }, 
      { 
        text: "Paste" 
      } 
    ]; 
    this.btnClick = this.btnClick.bind(this); 
  } 
  btnClick() { 
    this.cMenu.open(100, 40); 
  } 
  render() { 
    return ( 
      <div className="container"> 
        <ContextMenuComponent 
          id="contextmenu" 
          ref={scope => (this.cMenu = scope)} 
          items={this.menuItems} 
        /> 
        <ButtonComponent onClick={this.btnClick}> 
          Open ContextMenu 
        </ButtonComponent> 
      </div> 
    ); 
  } 
} 
ReactDom.render(<App />, document.getElementById("element")); 
 
 
 
For more details, please refer the below link 
 
 
Please let us know if you have any concern on this. 
 
Regards, 
Aravinthan S 



AM Amos April 23, 2021 05:31 PM UTC

You are right and Top = y and Left = X but in the docs it says https://ej2.syncfusion.com/react/documentation/context-menu/how-to/open-and-close-contextmenu/
In the following sample, the ContextMenu is opened using the open method at the specified position with X and Y coordinates
so it might be misleading because X is the second parameter and Y is the first one.



AS Aravinthan Seetharaman Syncfusion Team April 26, 2021 04:20 PM UTC

 
We have checked your query. We have noticed the incorrect parameter order in UG Documentation. We will consider and refresh our documentation in our next patch release which will be scheduled on 4th May 2021. We appreciate your patience until then. 
 
Regards, 
Aravinthan S

Loader.
Up arrow icon