Skip to content

Commit

Permalink
[FIX] table: update table style on header group removal
Browse files Browse the repository at this point in the history
The table styles were not updated when a header group was removed,
because UNGROUP_HEADERS wasn't handled.

closes #4995

Task: 4081345
X-original-commit: b57230f
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Adrien Minne (adrm) <[email protected]>
  • Loading branch information
hokolomopo committed Sep 18, 2024
1 parent bd30a22 commit 0ddac1b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/plugins/ui_feature/table_computed_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ const invalidateTableStyleCommands = [
"HIDE_COLUMNS_ROWS",
"UNHIDE_COLUMNS_ROWS",
"UNFOLD_HEADER_GROUP",
"UNGROUP_HEADERS",
"FOLD_HEADER_GROUP",
"FOLD_ALL_HEADER_GROUPS",
"UNFOLD_ALL_HEADER_GROUPS",
"FOLD_HEADER_GROUPS_IN_ZONE",
"UNFOLD_HEADER_GROUPS_IN_ZONE",
"CREATE_TABLE",
"UPDATE_TABLE",
"UPDATE_FILTER",
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/ui_stateful/filter_evaluation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class FilterEvaluationPlugin extends UIPlugin {
case "UNFOLD_HEADER_GROUP":
case "FOLD_ALL_HEADER_GROUPS":
case "UNFOLD_ALL_HEADER_GROUPS":
case "FOLD_HEADER_GROUPS_IN_ZONE":
case "UNFOLD_HEADER_GROUPS_IN_ZONE":
this.updateHiddenRows(cmd.sheetId);
break;
case "UPDATE_FILTER":
Expand Down
24 changes: 24 additions & 0 deletions tests/table/table_computed_style_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
createTable,
deleteContent,
deleteTable,
foldAllHeaderGroups,
foldHeaderGroup,
foldHeaderGroupsInZone,
groupRows,
hideColumns,
hideRows,
Expand All @@ -15,7 +17,10 @@ import {
setStyle,
setZoneBorders,
undo,
unfoldAllHeaderGroups,
unfoldHeaderGroup,
unfoldHeaderGroupsInZone,
ungroupHeaders,
unhideColumns,
unhideRows,
updateFilter,
Expand Down Expand Up @@ -215,6 +220,25 @@ describe("Table style", () => {
expect(getFullTableStyle("A1:B4")).not.toEqual(tableStyle);
unfoldHeaderGroup(model, "ROW", 0, 2);
expect(getFullTableStyle("A1:B4")).toEqual(tableStyle);

foldHeaderGroupsInZone(model, "ROW", "B1:B2");
expect(getFullTableStyle("A1:B4")).not.toEqual(tableStyle);
unfoldHeaderGroupsInZone(model, "ROW", "B1:B2");
expect(getFullTableStyle("A1:B4")).toEqual(tableStyle);

foldAllHeaderGroups(model, "ROW");
expect(getFullTableStyle("A1:B4")).not.toEqual(tableStyle);
unfoldAllHeaderGroups(model, "ROW");
expect(getFullTableStyle("A1:B4")).toEqual(tableStyle);
});

test("Table style is updated when removing a header group", () => {
const tableStyle = getFullTableStyle("A1:B4");
groupRows(model, 0, 2);
foldHeaderGroup(model, "ROW", 0, 2);
expect(getFullTableStyle("A1:B4")).not.toEqual(tableStyle);
ungroupHeaders(model, "ROW", 0, 2);
expect(getFullTableStyle("A1:B4")).toEqual(tableStyle);
});

test("Table style is updated when (un)filtering headers", () => {
Expand Down

0 comments on commit 0ddac1b

Please sign in to comment.