diff --git a/packages/studio/src/components/editor/domEditInlineText.ts b/packages/studio/src/components/editor/domEditInlineText.ts index 14bbbc89fe..16089fd4b9 100644 --- a/packages/studio/src/components/editor/domEditInlineText.ts +++ b/packages/studio/src/components/editor/domEditInlineText.ts @@ -48,6 +48,7 @@ export function canEditTextInline(selection: DomEditSelection | null): boolean { export function canEditSealedTextInline(selection: DomEditSelection | null): boolean { if (!selection?.handle || selection.isCompositionHost) return false; if (selection.isInsideLockedComposition || selection.textMarkup === false) return false; + if (!selection.textContent?.trim()) return false; return !["BODY", "HTML"].includes(selection.tagName.toUpperCase()); } diff --git a/packages/studio/src/hooks/inlineTextEdit.sealed.test.ts b/packages/studio/src/hooks/inlineTextEdit.sealed.test.ts index 413c938ec3..0c2d857093 100644 --- a/packages/studio/src/hooks/inlineTextEdit.sealed.test.ts +++ b/packages/studio/src/hooks/inlineTextEdit.sealed.test.ts @@ -18,7 +18,10 @@ import { afterStudioManualEditGestures, isStudioManualEditGestureLiveIn, } from "../components/editor/manualEditGesture"; -import { canEditSealedTextInline } from "../components/editor/domEditInlineText"; +import { + canEditElementTextInline, + canEditSealedTextInline, +} from "../components/editor/domEditInlineText"; import { sealedPreviewFrame } from "../player/lib/sealedPreviewFrame.test-helpers"; import { describePreviewElements, previewTextEdit } from "../player/lib/previewElements"; import { keepKeyboardOutOfSealedFrame } from "../player/lib/sealedFrameKeyboard"; @@ -964,6 +967,18 @@ it("opens no sealed text edit on a layer the frame would refuse, so Enter stays expect(canEditSealedTextInline(await select(iframe, "p"))).toBe(true); }); +// fails without the fix: a sealed empty box opened a text edit, so the press that dragged it after its select click +// was taken as a double press and the drag moved nothing (edit bench seqab-none-px-r0-nested-z100). +it("opens no sealed text edit on a box with no text, as a regular preview opens none", async () => { + document.body.innerHTML = `
x
`; + const { iframe } = sealedFrame(); + for (const id of ["box", "blank"]) { + expect(canEditElementTextInline(document.getElementById(id))).toBe(false); + expect(canEditSealedTextInline(await select(iframe, id))).toBe(false); + } + expect(canEditSealedTextInline(await select(iframe, "p"))).toBe(true); +}); + it("holds the pending-edit drain until a save the frame started on blur lands", async () => { await vi.waitFor(() => expect(hasStudioPendingEdits()).toBe(false)); const { title, selection } = await sealedTitle();