diff --git a/src/plugins/columnSorting/columnSorting.js b/src/plugins/columnSorting/columnSorting.js index 0e3894f7d8..97746c7540 100644 --- a/src/plugins/columnSorting/columnSorting.js +++ b/src/plugins/columnSorting/columnSorting.js @@ -791,7 +791,7 @@ class ColumnSorting extends BasePlugin { */ onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) { // Click below the level of column headers - if (coords.row >= 0) { + if (coords.row >= 0 || coords.col < 0) { return; } @@ -809,7 +809,7 @@ class ColumnSorting extends BasePlugin { */ onAfterOnCellMouseDown(event, coords) { // Click below the level of column headers - if (coords.row >= 0) { + if (coords.row >= 0 || coords.col < 0) { return; } diff --git a/src/plugins/columnSorting/test/columnSorting.e2e.js b/src/plugins/columnSorting/test/columnSorting.e2e.js index 25a1bc7dc8..0542b58033 100644 --- a/src/plugins/columnSorting/test/columnSorting.e2e.js +++ b/src/plugins/columnSorting/test/columnSorting.e2e.js @@ -332,6 +332,23 @@ describe('ColumnSorting', () => { ]); }); + it('should not throw an exception when clicked on the top-left corner', async() => { + const onErrorSpy = spyOn(window, 'onerror'); + + handsontable({ + colHeaders: true, + rowHeaders: true, + data: arrayOfObjects(), + columnSorting: true + }); + + $('.ht_clone_top_left_corner .htCore span').simulate('mousedown'); + $('.ht_clone_top_left_corner .htCore span').simulate('click'); + $('.ht_clone_top_left_corner .htCore span').simulate('mouseup'); + + expect(onErrorSpy).not.toHaveBeenCalled(); + }); + it('should not throw error when trying run handsontable with columnSorting and autoRowSize in the same time.', () => { let errors = 0;