From 31722de2ebd577f5625168b474e7e6a2e8f966a2 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Mon, 20 May 2024 21:27:24 -0700 Subject: [PATCH] (core) Fix drag selection bug in add row Summary: Relaxes selection restrictions on the add row, which was causing a bug where the row above the add row was also being selected whenever drag selection was started from the add row. Test Plan: Browser test. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D4253 --- app/client/components/GridView.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/client/components/GridView.js b/app/client/components/GridView.js index 8d8c6acc..e59577ec 100644 --- a/app/client/components/GridView.js +++ b/app/client/components/GridView.js @@ -1058,11 +1058,14 @@ GridView.prototype.getMousePosRow = function (yCoord) { /** * Returns the row index of the row whose top offset is closest to and - * no greater than given y-position excluding addRows. + * no greater than given y-position. * param{yCoord}: The mouse y-position on the screen. **/ GridView.prototype.currentMouseRow = function(yCoord) { - return Math.min(this.getMousePosRow(this.scrollTop() + yCoord), Math.max(0, this.getLastDataRowIndex())); + return Math.min( + this.getMousePosRow(this.scrollTop() + yCoord), + Math.max(0, this.getLastDataRowIndex() + 1) + ); }; /** @@ -1501,8 +1504,7 @@ GridView.prototype.buildDom = function() { dom.on('mousedown', () => false), testId('row-menu-trigger'), ), - kd.toggleClass('selected', () => - !row._isAddRow() && self.cellSelector.isRowSelected(row._index())), + kd.toggleClass('selected', () => self.cellSelector.isRowSelected(row._index())), ), dom('div.record', kd.toggleClass('record-add', row._isAddRow), @@ -1557,8 +1559,7 @@ GridView.prototype.buildDom = function() { }); var fieldBuilder = self.fieldBuilders.at(field._index()); var isSelected = ko.computed(() => { - return !row._isAddRow() && - !self.cellSelector.isCurrentSelectType(selector.NONE) && + return !self.cellSelector.isCurrentSelectType(selector.NONE) && ko.unwrap(self.isColSelected.at(field._index())) && self.cellSelector.isRowSelected(row._index()); });