mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fixing cursor position for filtered linked section.
Summary: In a selector table, when a selected row is filtered out of view, linked widgets should update based on the newly selected row. There were a few bugs that contributed to this wrong behavior: - Gridview wasn't subscribing to the current row id, and the row with id 'new' was being converted to the first row - Cursor was keeping track of the currently selected row id, it was hiding a problem behind the proper rowIndex - Undo/redo somehow leveraged the wrong rowId from the cursor during the position restore. The `No data` text was also changed to be more meaningful. Test Plan: Added and updated. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3937
This commit is contained in:
@@ -476,6 +476,7 @@ export class GristDoc extends DisposableWithEvents {
|
||||
const viewId = toKo(ko, this.activeViewId)();
|
||||
if (!isViewDocPage(viewId)) { return null; }
|
||||
const section = this.viewModel.activeSection();
|
||||
if (section?.isDisposed()) { return null; }
|
||||
const view = section.viewInstance();
|
||||
return view;
|
||||
})));
|
||||
@@ -620,6 +621,11 @@ export class GristDoc extends DisposableWithEvents {
|
||||
public async setCursorPos(cursorPos: CursorPos) {
|
||||
if (cursorPos.sectionId && cursorPos.sectionId !== this.externalSectionId.get()) {
|
||||
const desiredSection: ViewSectionRec = this.docModel.viewSections.getRowModel(cursorPos.sectionId);
|
||||
// If the section id is 0, the section doesn't exist (can happen during undo/redo), and should
|
||||
// be fixed there. For now ignore it, to not create empty sections or views (peeking a view will create it).
|
||||
if (!desiredSection.id.peek()) {
|
||||
return;
|
||||
}
|
||||
// If this is completely unknown section (without a parent), it is probably an import preview.
|
||||
if (!desiredSection.parentId.peek() && !desiredSection.isRaw.peek()) {
|
||||
const view = desiredSection.viewInstance.peek();
|
||||
|
||||
Reference in New Issue
Block a user