mirror of
https://github.com/penpot/penpot.git
synced 2026-07-22 14:08:03 +00:00
🐛 Fix text editor not auto-selecting all text on mount (#10573)
This commit is contained in:
parent
3ee5b50007
commit
3469867cf5
@ -129,3 +129,27 @@ test("BUG 10467 - Auto-width text captures every typed character", async ({
|
||||
await workspace.waitForSelectedShapeName("hello world");
|
||||
});
|
||||
|
||||
test("BUG 10531 - Entering the editor auto-selects the whole text", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = new WasmWorkspacePage(page, { textEditor: true });
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockGetFile("text-editor/get-file-lorem-ipsum.json");
|
||||
await workspace.goToWorkspace();
|
||||
await workspace.waitForFirstRender();
|
||||
|
||||
// Select the existing text shape and enter edit mode via Enter
|
||||
await workspace.clickLeafLayer("Lorem ipsum");
|
||||
await workspace.textEditor.startEditing();
|
||||
|
||||
// Copying while editing exports only the selected text as raw text.
|
||||
// Since we just entered the editor, the whole text should be selected.
|
||||
await workspace.copy("keyboard");
|
||||
|
||||
// Assert the text was copied correctly
|
||||
const copiedText = await page.evaluate(() =>
|
||||
navigator.clipboard.readText(),
|
||||
);
|
||||
expect(copiedText).toBe("Lorem ipsum");
|
||||
});
|
||||
|
||||
|
||||
@ -350,7 +350,10 @@
|
||||
(mf/deps contenteditable-ref)
|
||||
(fn []
|
||||
(when-let [node (mf/ref-val contenteditable-ref)]
|
||||
(.focus node))
|
||||
;; Focus and select all text on mount (this will trigger on-focus)
|
||||
(.focus node)
|
||||
(text-editor/text-editor-select-all)
|
||||
(wasm.api/request-render "text-editor-select-all-on-mount"))
|
||||
;; On unmount, finalize the editor content and then dispose the WASM editor.
|
||||
;; We finalize on unmount instead of relying on the browser blur event, because
|
||||
;; it was not being reliable (timing issues, Firefox issues…)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user