diff --git a/public/themes/bootstrap/scss/_tables.scss b/public/themes/bootstrap/scss/_tables.scss index 19b748c279..37d941061c 100644 --- a/public/themes/bootstrap/scss/_tables.scss +++ b/public/themes/bootstrap/scss/_tables.scss @@ -8,6 +8,10 @@ .cell-selected { outline: 1px solid #7facd6; + + &.with-bg-color { + background-color: #d0e4f7; + } } } diff --git a/public/themes/metro/scss/_tables.scss b/public/themes/metro/scss/_tables.scss index 0f6ad7d028..776b66985d 100644 --- a/public/themes/metro/scss/_tables.scss +++ b/public/themes/metro/scss/_tables.scss @@ -33,6 +33,10 @@ .cell-selected { outline: 1px solid #7facd6; + + &.with-bg-color { + background-color: #d0e4f7; + } } } diff --git a/public/themes/original/scss/_tables.scss b/public/themes/original/scss/_tables.scss index a0a3ce4f8a..6aa646ddcc 100644 --- a/public/themes/original/scss/_tables.scss +++ b/public/themes/original/scss/_tables.scss @@ -30,6 +30,10 @@ .cell-selected { outline: 1px solid #7facd6; + + &.with-bg-color { + background-color: #d0e4f7; + } } } diff --git a/public/themes/pmahomme/scss/_tables.scss b/public/themes/pmahomme/scss/_tables.scss index 779698ca63..7cb30bd307 100644 --- a/public/themes/pmahomme/scss/_tables.scss +++ b/public/themes/pmahomme/scss/_tables.scss @@ -32,6 +32,10 @@ .cell-selected { outline: 1px solid #7facd6; + + &.with-bg-color { + background-color: #d0e4f7; + } } } diff --git a/resources/js/makegrid.ts b/resources/js/makegrid.ts index f6eef8b919..54c7f1d545 100644 --- a/resources/js/makegrid.ts +++ b/resources/js/makegrid.ts @@ -2391,7 +2391,7 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine function renderCellSelection () { g.renderedSelectedCells.clear(); - $(g.t).find('.cell-selected').removeClass(selectingClass); + $(g.t).find(`.${selectingClass}`).removeClass(selectingClass).removeClass('with-bg-color'); if (g.selectedColumns.size === 0) { return; } @@ -2402,7 +2402,7 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine const columns = rowIndex === -1 ? $(g.t).find('thead tr').eq(0).find('th').eq(cellIndex - colspan) : $(g.t).find('tbody tr').eq(rowIndex).find('td').eq(cellIndex); - columns.addClass(selectingClass); + columns.addClass((g.selectedColumns.size === 1 && g.selectedRows.size === 1) ? selectingClass : `${selectingClass} with-bg-color`); }); }); } @@ -2456,12 +2456,7 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine // Keyboard events for cell selection $(document).on('keydown', function (e) { - // add throttle to avoid multiple events firing too quickly - if (keyboardEventTimestamp && (Date.now() - keyboardEventTimestamp) < 100) { - return; - } - keyboardEventTimestamp = Date.now(); if (document.activeElement && $(document.activeElement).is('input, textarea, select')) { return; // do not interfere with input fields @@ -2474,10 +2469,17 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine // Select all cells with header $(g.t).find('tbody > tr, thead > tr').each(function () { - $(this).find('td.data, th:not(.column_action)').addClass(selectingClass); + $(this).find('td.data, th:not(.column_action)').addClass(`${selectingClass} with-bg-color`); }); } + // add throttle to avoid multiple events firing too quickly + if (keyboardEventTimestamp && (Date.now() - keyboardEventTimestamp) < 100) { + return; + } + + keyboardEventTimestamp = Date.now(); + // arrow + shift to select cells if (e.shiftKey && g.endSelectCell) { const allowedSelectorToSelect = '.column_heading, .data'; @@ -2586,7 +2588,7 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine } if (!e.ctrlKey && !e.metaKey) { - $(g.t).find('.cell-selected').removeClass(selectingClass); + $(g.t).find(`.${selectingClass}`).removeClass(`${selectingClass} with-bg-color`); resetCellSelection(); isMultiselect = false; } else { @@ -2652,7 +2654,7 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine return; } - if ($(g.t).find('.cell-selected').length > 0) { + if ($(g.t).find(`.${selectingClass}`).length > 0) { let selectionText = ''; const headers: string[] = [];