From 12a7059bde765f5984819b747e6213b68deac133 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Tue, 15 Dec 2020 18:52:21 -0500 Subject: [PATCH] (core) Fix bug with pasting in the presence of link-filtering. Summary: The bug manifested when multiple grid cells were selected, and then user selected a record in another section that caused the grid to show a different set of rows. Paste would then go into multiple rows even when they are not visibly selected. The test includes some porting of hacks from old browser tests to support copy-pasting. In particular gu.sendKeys() is a useful alternative to driver.find('body').sendKeys() which we've been using to work around driver.sendKeys() limitations, but which apparently causes flakiness with focus. Test Plan: Browser test reproduces the bug before the fix. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2692 --- app/client/components/BaseView.js | 9 ++++++++- app/client/components/GridView.js | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/client/components/BaseView.js b/app/client/components/BaseView.js index 6d1e295a..106ea871 100644 --- a/app/client/components/BaseView.js +++ b/app/client/components/BaseView.js @@ -212,7 +212,7 @@ function BaseView(gristDoc, viewSectionModel, options) { })); // Reset cursor to the first row when filtering changes. - this.autoDispose(this._linkingFilter.subscribe((x) => this.setCursorPos({rowIndex: 0}))); + this.autoDispose(this._linkingFilter.subscribe((x) => this.onLinkFilterChange())); // When sorting changes, reset the cursor to the first row. (The alternative of moving the // cursor to stay at the same record is sometimes better, but sometimes more annoying.) @@ -604,6 +604,13 @@ BaseView.prototype.onResize = function() { BaseView.prototype.onRowResize = function(rowModels) { }; +/** + * Called when user selects a different row which drives the link-filtering of this section. + */ +BaseView.prototype.onLinkFilterChange = function(rowId) { + this.setCursorPos({rowIndex: 0}); +}; + /** * Called before and after printing this section. */ diff --git a/app/client/components/GridView.js b/app/client/components/GridView.js index 2da241fb..6656da14 100644 --- a/app/client/components/GridView.js +++ b/app/client/components/GridView.js @@ -963,6 +963,11 @@ GridView.prototype.onRowResize = function(rowModels) { this.scrolly.resetItemHeights(rowModels); }; +GridView.prototype.onLinkFilterChange = function(rowId) { + BaseView.prototype.onLinkFilterChange.call(this, rowId); + this.clearSelection(); +}; + // ====================================================================================== // SELECTOR STUFF