🐛 Fix update canvas background color

This commit is contained in:
Elena Torro 2025-07-24 16:27:46 +02:00 committed by Belén Albeza
parent 4189d01844
commit 2b95e6b7a9
3 changed files with 24 additions and 0 deletions

View file

@ -138,3 +138,26 @@ test("Renders shapes with exif rotated images fills and strokes", async ({
await expect(workspace.canvas).toHaveScreenshot(); await expect(workspace.canvas).toHaveScreenshot();
}); });
test("Updates canvas background", async ({
page,
}) => {
const workspace = new WasmWorkspacePage(page);
await workspace.setupEmptyFile();
await workspace.mockGetFile("render-wasm/get-file-text.json");
await workspace.goToWorkspace({
id: "3b0d758a-8c9d-8013-8006-52c8337e5c72",
pageId: "3b0d758a-8c9d-8013-8006-52c8337e5c73",
});
await workspace.waitForFirstRender({ hideUI: false });
const canvasBackgroundInput = workspace.page.getByRole("textbox", { name: 'Color' });
await canvasBackgroundInput.fill("FABADA");
await workspace.page.keyboard.press("Enter");
// can't hide UI cause this will trigger a re-render
// await workspace.hideUI();
await expect(workspace.canvas).toHaveScreenshot();
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View file

@ -115,6 +115,7 @@ pub extern "C" fn set_canvas_background(raw_color: u32) {
with_state_mut!(state, { with_state_mut!(state, {
let color = skia::Color::new(raw_color); let color = skia::Color::new(raw_color);
state.set_background_color(color); state.set_background_color(color);
state.rebuild_tiles();
}); });
} }