JSFiddle - React, Tailwind, and code Playground

by Flexmonster Pivot Table

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div id="wrapper">
  <div id="pivotContainer"></div>
</div>

CSS

#wrapper {
  width: 500px;
  height: 300px;
  overflow: hidden;
}

/* .fm-context-menu {
   position: absolute !important;
} */

JavaScript

let pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  width: "100%",
  height: "100%",
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    options: {
      grid: {
        type: "classic"
      }
    }
  }
});

pivot.customizeContextMenu(function(items, data, viewType) {
  adjustContextMenu();
  return items;
});

function adjustContextMenu() {
  setTimeout(() => {
    const contextMenu = document.querySelector(".fm-context-menu");
    const wrapper = document.querySelector("#wrapper");
    let contextMenuBox = contextMenu.getBoundingClientRect();
    let wrapperBox = wrapper.getBoundingClientRect();
    const diff = (wrapperBox.y + wrapperBox.height) - (contextMenuBox.y + contextMenuBox.height);
    console.log(contextMenu.style.top);
    if (diff < 0) {
      contextMenu.style.top = parseInt(contextMenu.style.top) + diff + "px";
      console.log(contextMenu.style.top);
    }
  }, 10);
}

function getCoordinates(element) {
  let box = element.getBoundingClientRect();
  console.log(box);
  let body = document.body;
  let docEl = document.documentElement;
  let scrollTop = window.pageYOffset;
  let scrollLeft = window.pageXOffset;
  let clientTop = docEl.clientTop;
  let clientLeft = docEl.clientLeft;
  let top = box.top + scrollTop - clientTop;
  let left = box.left + scrollLeft - clientLeft;
  return {
    top: Math.round(top),
    left: Math.round(left)
  };
}