From 2a3328abfcbb204baeaa93b320d51ae01678396a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Fri, 9 Sep 2022 11:31:26 +0200 Subject: [PATCH] (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 --- app/client/components/GridView.js | 3 ++- test/nbrowser/gristUtils.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/client/components/GridView.js b/app/client/components/GridView.js index 6a1afbb2..39a86760 100644 --- a/app/client/components/GridView.js +++ b/app/client/components/GridView.js @@ -299,6 +299,7 @@ GridView.gridCommands = { .finally(() => { this.cursor.setCursorPos(saved); this.cursor.setLive(true); + this.clearSelection(); }) .catch(reportError); }, @@ -719,7 +720,7 @@ GridView.prototype.deleteColumns = function(selection) { let actions = fields.filter(col => !col.disableModify()).map(col => ['RemoveColumn', col.colId()]); if (actions.length > 0) { 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()); } }; diff --git a/test/nbrowser/gristUtils.ts b/test/nbrowser/gristUtils.ts index 5d34c02b..997f1f8f 100644 --- a/test/nbrowser/gristUtils.ts +++ b/test/nbrowser/gristUtils.ts @@ -1519,6 +1519,11 @@ export function openRowMenu(rowNum: number) { .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) { const section = await driver.find('.active_section'); const firstRow = await section.findContent('.detail_row_num', String(rowNum));