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