Skip to content

Commit ca97824

Browse files
committed
[FIX] Tables: invalidate computed style on DELETE_CONTENT
The command `DELETE_CONTENT` can sometimes dispatch a subcommand that deletes a table, which implies that the table style and therefore the cell computed style need to be invalidated. Since the subcommand does not reach Ui feature plugins when replaying commands, we need to explicitely invalidate the table & cell styles on `DELETE_CONTENT`. closes #8839 Task: 6253199 X-original-commit: cfcb7c9 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com> Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent eb64a11 commit ca97824

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/plugins/ui_feature/table_computed_style.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ const invalidateTableStyleCommands = [
276276
"RESIZE_TABLE",
277277
"CREATE_TABLE_STYLE",
278278
"REMOVE_TABLE_STYLE",
279+
"DELETE_CONTENT",
279280
] as const;
280281
const invalidateTableStyleCommandsSet = new Set<CommandTypes>(invalidateTableStyleCommands);
281282

tests/collaborative/collaborative.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import {
7070
getMerges,
7171
getStyle,
7272
} from "../test_helpers/getters_helpers";
73-
import { addToRegistry, getDataValidationRules } from "../test_helpers/helpers";
73+
import { addToRegistry, getDataValidationRules, toCellPosition } from "../test_helpers/helpers";
7474
import { addPivot, updatePivot } from "../test_helpers/pivot_helpers";
7575
import { setupCollaborativeEnv } from "./collaborative_helpers";
7676

@@ -922,6 +922,22 @@ describe("Multi users synchronisation", () => {
922922
);
923923
});
924924

925+
test("deleting a cell content properly deletes the table and invalidates its computed style", () => {
926+
const sheetId = alice.getters.getActiveSheetId();
927+
setCellContent(alice, "A1", "hello");
928+
createTable(alice, "A1:A2");
929+
const A1 = toCellPosition(sheetId, "A1");
930+
expect([alice, bob, charlie]).toHaveSynchronizedValue(
931+
(user) => user.getters.getCellComputedStyle(A1),
932+
{ bold: true, fillColor: "#346B90", textColor: "#FFFFFF" }
933+
);
934+
deleteContent(alice, ["A1:A2"]);
935+
expect([alice, bob, charlie]).toHaveSynchronizedValue(
936+
(user) => user.getters.getCellComputedStyle(A1),
937+
{}
938+
);
939+
});
940+
925941
test.each(["COL", "ROW"] as const)("Can group headers concurrently", (dimension) => {
926942
const sheetId = alice.getters.getActiveSheetId();
927943

0 commit comments

Comments
 (0)