mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
fix(studio): a sealed empty box drags on the press right after its select click (#8772)
* test(studio): a sealed box with no text opens no text edit * fix(studio): a sealed box with no text drags on the press after its select click
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = `<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();
|
||||
|
||||
Reference in New Issue
Block a user