(core) Scrolling to the active record on search

Summary:
Two bugs fixed:
1. On search, when the first result is in the active record, GridView wasn't scrolling to the active record.
2. When an active record was not visible, GridView wasn't scrolling to the active record when the column index was changed.

The problem was that the scrolling behavior was based only on rowIndex which isn't changed (and doesn't notify subscribers) when a column index changes or when the search highlights a cell.
This diff makes the computed depend also on the fieldIndex, and is introducing a new method that can scroll to the active record on demand (which is used by the search).

Test Plan: Updated tests.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3191
This commit is contained in:
Jarosław Sadziński
2021-12-16 19:00:04 +01:00
parent d08fdd772e
commit c1de16aee7
5 changed files with 67 additions and 20 deletions

View File

@@ -309,9 +309,12 @@ class FinderImpl implements IFinder {
// this ad-hoc way rather than use observables, to avoid the overhead of *every* cell
// depending on an additional observable.
await delay(0);
const viewInstance = await waitObs<any>(section.viewInstance);
const viewInstance = (await waitObs(section.viewInstance))!;
await viewInstance.getLoadingDonePromise();
if (this._aborted) { return; }
// Make sure we are at good place. This is important when the cursor
// was already in a matched record, but the record was scrolled away.
await viewInstance.revealActiveRecord();
const cursor = viewInstance.viewPane.querySelector('.selected_cursor');
if (cursor) {