(core) Fixing bug with hiding multiple columns

Summary:
Selection in GridView wasn't updated when fields were removed, and the selected
column index was out of bounds.

Test Plan: New test added

Reviewers: JakubSerafin

Reviewed By: JakubSerafin

Differential Revision: https://phab.getgrist.com/D4137
This commit is contained in:
Jarosław Sadziński
2023-12-07 13:42:24 +01:00
parent 8038ee881c
commit d0318af39b
2 changed files with 24 additions and 4 deletions

View File

@@ -39,6 +39,10 @@ export class CellSelector extends Disposable {
super();
this.autoDispose(this.view.cursor.rowIndex.subscribe(() => this.setToCursor()));
this.autoDispose(this.view.cursor.fieldIndex.subscribe(() => this.setToCursor()));
const fieldsLength = this.autoDispose(ko.pureComputed(() => this.view.viewSection.viewFields().all().length));
this.autoDispose(fieldsLength.subscribe((length) => {
this.col.end(Math.min(this.col.end.peek(), length - 1));
}));
this.setToCursor();
}