(core) Clearing selection after rows or cols were removed

Summary:
The selection was not cleared after removing rows, and it still
kept deleted rows ids. Removing selected rows once again
produced an assertion error.
Also, the selection is now cleared when columns are removed.

Test Plan: Updated tests

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3623
This commit is contained in:
Jarosław Sadziński 2022-09-09 11:31:26 +02:00
parent 56624c4a95
commit 2a3328abfc
2 changed files with 7 additions and 1 deletions

View File

@ -299,6 +299,7 @@ GridView.gridCommands = {
.finally(() => { .finally(() => {
this.cursor.setCursorPos(saved); this.cursor.setCursorPos(saved);
this.cursor.setLive(true); this.cursor.setLive(true);
this.clearSelection();
}) })
.catch(reportError); .catch(reportError);
}, },
@ -719,7 +720,7 @@ GridView.prototype.deleteColumns = function(selection) {
let actions = fields.filter(col => !col.disableModify()).map(col => ['RemoveColumn', col.colId()]); let actions = fields.filter(col => !col.disableModify()).map(col => ['RemoveColumn', col.colId()]);
if (actions.length > 0) { if (actions.length > 0) {
this.tableModel.sendTableActions(actions, `Removed columns ${actions.map(a => a[1]).join(', ')} ` + this.tableModel.sendTableActions(actions, `Removed columns ${actions.map(a => a[1]).join(', ')} ` +
`from ${this.tableModel.tableData.tableId}.`); `from ${this.tableModel.tableData.tableId}.`).then(() => this.clearSelection());
} }
}; };

View File

@ -1519,6 +1519,11 @@ export function openRowMenu(rowNum: number) {
.then(() => driver.findWait('.grist-floating-menu', 1000)); .then(() => driver.findWait('.grist-floating-menu', 1000));
} }
export async function removeRow(rowNum: number) {
await (await openRowMenu(rowNum)).findContent('li', /Delete/).click();
await waitForServer();
}
export async function openCardMenu(rowNum: number) { export async function openCardMenu(rowNum: number) {
const section = await driver.find('.active_section'); const section = await driver.find('.active_section');
const firstRow = await section.findContent('.detail_row_num', String(rowNum)); const firstRow = await section.findContent('.detail_row_num', String(rowNum));