mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix some bugs with repositioning rows.
Summary: - Fixed an issue with manualSort values being very close floats. It is already handled by the data engine, but the client was being unnecessarily proactive and introduced a bug. - The fix also helps with rearranging rows in filtered situations: they will now stay next to the row before which they were inserted. - The fix accidentally improves (though doesn't fully fix) the issue where new columns show up in unexpected places in the raw-data column list. - Fixed another rare bug with row order not getting updated correctly when positions update. Test Plan: Added test cases for the improved behavior; fixed affected tests. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3462
This commit is contained in:
@@ -656,18 +656,10 @@ BaseView.prototype.scrollToCursor = function() {
|
||||
* with the returned positions will place them in between index-1 and index.
|
||||
* when the GridView is sorted by MANUALSORT
|
||||
**/
|
||||
BaseView.prototype._getRowInsertPos = function(index, numInserts) {
|
||||
var lowerRowId = this.viewData.getRowId(index-1);
|
||||
var upperRowId = this.viewData.getRowId(index);
|
||||
if (lowerRowId === 'new') {
|
||||
// set the lowerRowId to the rowId of the row before 'new'.
|
||||
lowerRowId = this.viewData.getRowId(index - 2);
|
||||
}
|
||||
|
||||
var lowerPos = this.tableModel.tableData.getValue(lowerRowId, MANUALSORT);
|
||||
var upperPos = this.tableModel.tableData.getValue(upperRowId, MANUALSORT);
|
||||
// tableUtil.insertPositions takes care of cases where upper/lowerPos are non-zero & falsy
|
||||
return tableUtil.insertPositions(lowerPos, upperPos, numInserts);
|
||||
BaseView.prototype._getRowInsertPos = function(index, numInserts) {
|
||||
var rowId = this.viewData.getRowId(index);
|
||||
var insertPos = this.tableModel.tableData.getValue(rowId, MANUALSORT);
|
||||
return Array(numInserts).fill(insertPos);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user