From de76cc48d178439f12ba9a19f12cd5594690568b Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Wed, 22 Sep 2021 22:08:31 +0200 Subject: [PATCH] (core) Move cursor to new record in link target when selecting new record in link source Summary: Update LinkingState._makeSrcCellGetter to account for 'new' Test Plan: Extended test in RightPanelSelectBy.ts Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3037 --- app/client/components/LinkingState.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/client/components/LinkingState.ts b/app/client/components/LinkingState.ts index 4248434f..e6f3b8ac 100644 --- a/app/client/components/LinkingState.ts +++ b/app/client/components/LinkingState.ts @@ -59,7 +59,7 @@ type FilterColValues = Pick; */ export class LinkingState extends Disposable { // If linking affects target section's cursor, this will be a computed for the cursor rowId. - public readonly cursorPos?: ko.Computed; + public readonly cursorPos?: ko.Computed; // If linking affects filtering, this is a computed for the current filtering state, as a // {[colId]: colValues} mapping, with a dependency on srcSection.activeRowId() @@ -119,7 +119,7 @@ export class LinkingState extends Disposable { const srcValueFunc = srcColId ? this._makeSrcCellGetter() : _.identity; if (srcValueFunc) { this.cursorPos = this.autoDispose(ko.computed(() => - srcValueFunc(srcSection.activeRowId()) as number + srcValueFunc(srcSection.activeRowId()) as RowId )); } } @@ -178,6 +178,9 @@ export class LinkingState extends Disposable { } return (rowId: RowId | null) => { srcRowModel.assign(rowId); + if (rowId === 'new') { + return 'new'; + } return srcCellObs(); }; }