Skip to content

Commit

Permalink
[FIX] FiltersPlugin: removing row with data filter header
Browse files Browse the repository at this point in the history
Previously, removing rows that included the filter header failed to remove
the associated data filter tables.

This commit addresses the issue by ensuring the data filter tables is also
removed when rows with the filter header are deleted.

closes #3160

Task: 3546012
X-original-commit: d15825d
Signed-off-by: Rémi Rahir (rar) <[email protected]>
Signed-off-by: Dhrutik Patel (dhrp) <[email protected]>
  • Loading branch information
dhrp-odoo committed Nov 16, 2023
1 parent 1013eed commit 94f7eb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/plugins/core/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ export class FiltersPlugin extends CorePlugin<FiltersState> implements FiltersSt

private onDeleteColumnsRows(cmd: RemoveColumnsRowsCommand) {
for (const table of this.getFilterTables(cmd.sheetId)) {
// Remove the filter tables whose data filter headers are in the removed rows.
if (cmd.dimension === "ROW" && cmd.elements.includes(table.zone.top)) {
const tables = { ...this.tables[cmd.sheetId] };
delete tables[table.id];
this.history.update("tables", cmd.sheetId, tables);
continue;
}

const zone = reduceZoneOnDeletion(
table.zone,
cmd.dimension === "COL" ? "left" : "top",
Expand Down
10 changes: 2 additions & 8 deletions tests/plugins/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,9 @@ describe("Filters plugin", () => {
]);
});

test("On the left part of the zone", () => {
test("Removing rows with filter table should remove the filter table", () => {
deleteRows(model, [2]);
expect(model.getters.getFilterTables(sheetId)[0].zone).toEqual(toZone("C3:F5"));
expect(getFilterValues(model)).toEqual([
{ zone: "C3:C5", value: ["C"] },
{ zone: "D3:D5", value: ["D"] },
{ zone: "E3:E5", value: ["E"] },
{ zone: "F3:F5", value: ["F"] },
]);
expect(model.getters.getFilterTables(sheetId)).toEqual([]);
});

test("Inside the zone", () => {
Expand Down

0 comments on commit 94f7eb8

Please sign in to comment.