From d94b1390711852fb0d3ad4535646c23727faed8f Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Fri, 24 Jul 2026 12:15:16 +0200 Subject: [PATCH] :bug: Fix text edition state when relesecting (#10798) * :bug: Fix text edition state when relesecting * :bug: Fix CI --- .../ui/specs/text-editor-v2.spec.js | 1 + .../playwright/ui/specs/tokens/text.spec.js | 47 +++++++++++++++++++ .../app/main/data/workspace/selection.cljs | 6 +-- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/frontend/playwright/ui/specs/text-editor-v2.spec.js b/frontend/playwright/ui/specs/text-editor-v2.spec.js index a58c71dba4..2219a4ea8c 100644 --- a/frontend/playwright/ui/specs/text-editor-v2.spec.js +++ b/frontend/playwright/ui/specs/text-editor-v2.spec.js @@ -344,6 +344,7 @@ test("Preserves empty fill after editing text without changes", async ({ page }) await workspace.createTextShape(190, 150, 300, 200, initialText); await workspace.textEditor.stopEditing(); + await workspace.page.getByRole('button', { name: 'Fill', exact: true }).click(); const fillColorButton = workspace.page.getByRole("button", { name: "#000000", diff --git a/frontend/playwright/ui/specs/tokens/text.spec.js b/frontend/playwright/ui/specs/tokens/text.spec.js index 3c34376934..d7b633fd34 100644 --- a/frontend/playwright/ui/specs/tokens/text.spec.js +++ b/frontend/playwright/ui/specs/tokens/text.spec.js @@ -1,4 +1,7 @@ import { test, expect } from "@playwright/test"; +import { + unfoldTokenType, +} from "./helpers"; import { WasmWorkspacePage } from "../../pages/WasmWorkspacePage"; test.beforeEach(async ({ page }) => { @@ -27,3 +30,47 @@ test("BUG 13958 - Fill token gets detached when editing text shape", async ({ pa // Assert token is still attached to the shape await expect(workspacePage.rightSidebar.getByLabel("xx.alias.color.text.default", { exact: true })).toBeVisible(); }); + +test("Selection change clears text-edition mode so tokens can be applied", async ({ page }) => { + const workspacePage = new WasmWorkspacePage(page); + await workspacePage.setupEmptyFile(); + await workspacePage.mockGetFile("workspace/get-file-13958.json"); + await workspacePage.goToWorkspace(); + await workspacePage.rectShapeButton.click(); + await workspacePage.clickWithDragViewportAt(128, 128, 200, 100); + await workspacePage.clickLeafLayer("Rectangle"); + + // Enter text editing on the text layer + await workspacePage.clickLeafLayer("Design tokens are a set"); + await workspacePage.page.keyboard.press("Enter"); + await expect(workspacePage.page.getByTestId("text-editor")).toBeVisible(); + + // Shift-click another layer to change selection while editing + await workspacePage.layers + .getByTestId("layer-row") + .filter({ hasText: "Rectangle" }) + .click({ modifiers: ["Shift"] }); + + // Text editor should close because selection change emits :interrupt + await expect(workspacePage.page.getByTestId("text-editor")).not.toBeAttached(); + + // Open tokens tab and try to apply a fill token — should succeed without warning + await page.getByRole("tab", { name: "Tokens" }).click(); + + const tokensSidebar = page.getByTestId("tokens-sidebar"); + + await unfoldTokenType(tokensSidebar, "color"); + + // Right-click a color token and apply as fill + await tokensSidebar + .getByRole('button', { name: '#934846 xx.global.color.red.' }) + .click({ button: "right" }); + await workspacePage.tokenContextMenuForToken.getByText("Fill").click(); + + // Verify no warning toast appeared about text editing + await expect( + page.getByRole("alert").filter({ + hasText: /Tokens can't be applied while editing text/i, + }), + ).not.toBeVisible(); +}); diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 4798517122..3eab8b2d6b 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -221,7 +221,7 @@ (ptk/reify ::deselect-shape ptk/WatchEvent (watch [_ _ _] - (rx/of ::dwsp/interrupt)) + (rx/of :interrupt ::dwsp/interrupt)) ptk/UpdateEvent (update [_ state] (-> state @@ -236,7 +236,7 @@ (ptk/reify ::shift-select-shapes ptk/WatchEvent (watch [_ _ _] - (rx/of ::dwsp/interrupt)) + (rx/of :interrupt ::dwsp/interrupt)) ptk/UpdateEvent (update [_ state] (let [objects (or objects (dsh/lookup-page-objects state)) @@ -275,7 +275,7 @@ ;; the event loop expand-s (->> (rx/of (dwc/expand-all-parents ids objects)) (rx/observe-on :async)) - interrupt-s (rx/of ::dwsp/interrupt)] + interrupt-s (rx/of :interrupt ::dwsp/interrupt)] (rx/merge expand-s interrupt-s))))) (defn select-all