Skip to content

Commit

Permalink
[FIX] paint format: copy conditional formats
Browse files Browse the repository at this point in the history
The paint format tool should also copy the conditional formats of the
source cells.

closes #5124

Task: 4226853
X-original-commit: 4f2950a
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
  • Loading branch information
hokolomopo committed Oct 23, 2024
1 parent 7177bf5 commit c2c24a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/paint_format_button/paint_format_store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ClipboardHandler } from "../../clipboard_handlers/abstract_clipboard_handler";
import { BorderClipboardHandler } from "../../clipboard_handlers/borders_clipboard";
import { CellClipboardHandler } from "../../clipboard_handlers/cell_clipboard";
import { ConditionalFormatClipboardHandler } from "../../clipboard_handlers/conditional_format_clipboard";
import { TableClipboardHandler } from "../../clipboard_handlers/tables_clipboard";
import { SELECTION_BORDER_COLOR } from "../../constants";
import { getClipboardDataPositions } from "../../helpers/clipboard/clipboard_helpers";
Expand All @@ -23,6 +24,7 @@ export class PaintFormatStore extends SpreadsheetStore {
new CellClipboardHandler(this.getters, this.model.dispatch),
new BorderClipboardHandler(this.getters, this.model.dispatch),
new TableClipboardHandler(this.getters, this.model.dispatch),
new ConditionalFormatClipboardHandler(this.getters, this.model.dispatch),
];

private status: "inactive" | "oneOff" | "persistent" = "inactive";
Expand Down
24 changes: 23 additions & 1 deletion tests/grid/grid_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ import {
getSelectionAnchorCellXc,
getStyle,
} from "../test_helpers/getters_helpers";
import { mockChart, mountSpreadsheet, nextTick, typeInComposerGrid } from "../test_helpers/helpers";
import {
createEqualCF,
mockChart,
mountSpreadsheet,
nextTick,
toRangesData,
typeInComposerGrid,
} from "../test_helpers/helpers";
import { mockGetBoundingClientRect } from "../test_helpers/mock_helpers";
jest.mock("../../src/components/composer/content_editable_helper", () =>
require("../__mocks__/content_editable_helper")
Expand Down Expand Up @@ -881,6 +888,21 @@ describe("Grid component", () => {
expect(getCell(model, "C8")?.style).toMatchObject({ fillColor: "#748747" });
});

test("Paste format works with conditional format", () => {
const sheetId = model.getters.getActiveSheetId();
model.dispatch("ADD_CONDITIONAL_FORMAT", {
cf: createEqualCF("1", { fillColor: "#0000FF" }, "cf2"),
sheetId,
ranges: toRangesData(sheetId, "A1"),
});
selectCell(model, "A1");
paintFormatStore.activate({ persistent: false });
gridMouseEvent(model, "pointerdown", "C8");
gridMouseEvent(model, "pointerup", "C8");

expect(model.getters.getConditionalFormats(sheetId)[0].ranges).toEqual(["A1", "C8"]);
});

test("can keep the paint format mode persistently", async () => {
setCellContent(model, "B2", "b2");
selectCell(model, "B2");
Expand Down

0 comments on commit c2c24a0

Please sign in to comment.