(core) Preserving cursor position when linked state is removed.

Summary:
- Preserving cursor position when linked state is removed.
- Moving linking tests to grist core.
- Disabling yarn offline mirror for grist-core. This helps testing grist-core when it is imported as a submodule.
- Moving one test for linked section from ReferenceColumns.ts to RightPanelSelectBy.ts.

Test Plan: Updated

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3795
This commit is contained in:
Jarosław Sadziński
2023-02-08 11:07:57 +01:00
parent 6e3f0f2b35
commit e93dd4bc6f
11 changed files with 1709 additions and 21 deletions

View File

@@ -140,8 +140,12 @@ function BaseView(gristDoc, viewSectionModel, options) {
return linking && linking.cursorPos ? linking.cursorPos() : null;
}).extend({deferred: true}));
// Update the cursor whenever linkedRowId() changes.
this.autoDispose(this.linkedRowId.subscribe(rowId => this.setCursorPos({rowId: rowId || 'new'})));
// Update the cursor whenever linkedRowId() changes (but only if we have any linking).
this.autoDispose(this.linkedRowId.subscribe(rowId => {
if (this.viewSection.linkingState.peek()) {
this.setCursorPos({rowId: rowId || 'new'});
}
}));
// Indicated whether editing the section should be disabled given the current linking state.
this.disableEditing = this.autoDispose(ko.computed(() => {
@@ -693,7 +697,11 @@ 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});
// If this section is linked, go to the first row as the row previously selected may no longer
// be visible.
if (this.viewSection.linkingState.peek()) {
this.setCursorPos({rowIndex: 0});
}
};
/**