<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Leksydepark</title>
    <description>The latest articles on DEV Community by Leksydepark (@iotele).</description>
    <link>https://dev.to/iotele</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1287788%2F1c4bbca9-5026-4e94-9728-d865893039c6.jpeg</url>
      <title>DEV Community: Leksydepark</title>
      <link>https://dev.to/iotele</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iotele"/>
    <language>en</language>
    <item>
      <title>Dynamic ContextMenu</title>
      <dc:creator>Leksydepark</dc:creator>
      <pubDate>Thu, 22 Feb 2024 12:34:50 +0000</pubDate>
      <link>https://dev.to/iotele/dynamic-contextmenu-30p3</link>
      <guid>https://dev.to/iotele/dynamic-contextmenu-30p3</guid>
      <description>&lt;p&gt;Hello Everyone, I am currently working on a project with an SVG layout for building that involves contextMenu, and the contextMenu needs to show the name of the clicked space at the first child of its list because a data attribute is in use.&lt;/p&gt;

&lt;p&gt;I need help on this project to be able to display the name of the clicked svg at the first list of the contextMenu.&lt;/p&gt;

&lt;p&gt;function handleContextMenu(event) {&lt;br&gt;
        event.preventDefault();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // Close any open context menu
    const openContextMenu = document.querySelector(".context-menu");
    if (openContextMenu) {
        openContextMenu.remove();
    }

    const posX = event.pageX;
    const posY = event.pageY;

    let dataName = this.getAttribute("data-name");

    let menuItems;
    if (this.classList.contains("officeArea")) {
        menuItems = [dataName,"Reception", "Creative", "BD", "Conference-Room","Procurement", "Head-BD","Finance","Director", "MD-PA","MD","Admin","IT"];
    } else {
        menuItems = [dataName,"Restroom","Creative-Lobby", "Walkway", "Stairs", "Procurement-Store","Game-Arena"];
    }

    const contextMenu = createContextMenu(menuItems);

    contextMenu.style.left = (posX - 1) + 'px';
    contextMenu.style.top = ( posY - 15) + 'px';
    contextMenu.style.display = 'block';



    document.body.append(contextMenu);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
