fix: disable drag on calender popup and unblock other input interactions

This commit is contained in:
Johnson Cherian 2024-05-28 13:18:41 +05:30
parent 15004bd633
commit c64d32e8ff

View file

@ -467,6 +467,12 @@ export default function DragContainer({
const box = boxes.find((box) => box.id === e.target.id);
let isDragOnTable = false;
/* If the drag or click is on a calender popup draggable interactions are not executed so that popups and other components inside calender popup works.
Also user dont need to drag an calender from using popup */
if (hasParentWithClass(e.inputEvent.target, 'react-datepicker-popper')) {
return false;
}
/* Checking if the dragged elemenent is a table. If its a table drag is disabled since it will affect column resizing and reordering */
if (box?.component?.component === 'Table') {
const tableElem = e.target.querySelector('.jet-data-table');
@ -842,3 +848,16 @@ function getOffset(childElement, grandparentElement) {
return { x: offsetX, y: offsetY };
}
function hasParentWithClass(child, className) {
let currentElement = child;
while (currentElement !== null && currentElement !== document.documentElement) {
if (currentElement.classList.contains(className)) {
return true;
}
currentElement = currentElement.parentElement;
}
return false;
}