Merge #20260 - Fix #20181 - allow selecting text fragments in cells

Pull-request: #20260
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2026-03-29 15:22:14 +02:00
commit 4246b6d9a4
No known key found for this signature in database
GPG Key ID: 70684F4717D49A31

View File

@ -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;
}