Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/studio/src/components/editor/domEditInlineText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
17 changes: 16 additions & 1 deletion packages/studio/src/hooks/inlineTextEdit.sealed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 = `<div id="box"></div><div id="blank"> </div><p id="p">x</p>`;
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();
Expand Down
Loading