Skip to content

Commit

Permalink
[FIX] style: recompute style on collaborative change
Browse files Browse the repository at this point in the history
Steps to reproduce:
- open the same spreadsheet in two different tabs
- in one of the tab, change the background color of some cells

=> the background is not updated in the other tab

The UPDATE_CELL command is not dispatched to `CellComputedStylePlugin` of
other clients because it's categorized as a "feature" plugin which is not
supposed to react to collaborative core (sub) commands. It currently reacts
to the root command.

The plugin cannot be a "core view" plugin because it depends on the filter
values, which is a UI state.

closes #4920

Task: 4141034
Signed-off-by: Pierre Rousseau (pro) <[email protected]>
  • Loading branch information
LucasLefevre committed Sep 10, 2024
1 parent c14a4c9 commit a74b5f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plugins/ui_feature/cell_computed_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class CellComputedStylePlugin extends UIPlugin {
if (
invalidateEvaluationCommands.has(cmd.type) ||
cmd.type === "UPDATE_CELL" ||
cmd.type === "SET_FORMATTING" ||
cmd.type === "EVALUATE_CELLS"
) {
this.styles = {};
Expand Down
13 changes: 13 additions & 0 deletions tests/collaborative/collaborative.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,19 @@ describe("Multi users synchronisation", () => {
);
});

test("background color is updated for each client", () => {
setCellContent(alice, "A1", "Hi");
expect([alice, bob, charlie]).toHaveSynchronizedValue(
(user) => getStyle(user, "A1").fillColor,
undefined
);
setStyle(bob, "A1", { fillColor: "#112233" });
expect([alice, bob, charlie]).toHaveSynchronizedValue(
(user) => getStyle(user, "A1").fillColor,
"#112233"
);
});

test.each(["COL", "ROW"] as const)("Can group headers concurrently", (dimension) => {
const sheetId = alice.getters.getActiveSheetId();

Expand Down

0 comments on commit a74b5f6

Please sign in to comment.