diff --git a/resources/js/makegrid.ts b/resources/js/makegrid.ts index 15f4d7e54e..b33be2bce7 100644 --- a/resources/js/makegrid.ts +++ b/resources/js/makegrid.ts @@ -2615,8 +2615,9 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine selectCell(this); - // Prevent text selection - e.preventDefault(); + $(g.t).on('mouseleave.cellSelect', 'td.data', function () { + window.getSelection().removeAllRanges(); + }); // Dynamic mouseover for drag $(g.t).on('mouseover.cellSelect', 'td.data, thead th:not(.column_action)', function (e) { @@ -2659,13 +2660,15 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine $(document).on('mouseup.cellSelect', function () { g.isSelectingCells = false; $(g.t).off('mouseover.cellSelect'); + $(g.t).off('mouseleave.cellSelect'); $(document).off('mouseup.cellSelect'); }); }); // Copy handler $(document).on('copy', function (e) { - if (!document.body.contains(g.t) || g.isCellEditActive) { + const selection = window.getSelection(); + if (!document.body.contains(g.t) || g.isCellEditActive || (selection.rangeCount > 0 && !selection.isCollapsed)) { return; }