From a5b284682c4580e1163cbc49f0953ee99932f2a9 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 23 Jun 2026 20:09:27 -0400 Subject: [PATCH] video-modal: fix Embed button doing nothing (wrong event name) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handleEmbedRequest dispatched "action:embed", but ModalManager listens for "video:embed" (which opens EmbedVideoModal) and dispatch() does not remap names — so the embed button fired an event into the void and the modal never opened. (Share survives the same mismatch only because shareBtn also toggles a popover directly.) Dispatch "video:embed". Regression test added. Co-Authored-By: Claude Opus 4.8 --- js/ui/components/VideoModal.js | 5 ++++- tests/video-modal-zap.test.mjs | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/js/ui/components/VideoModal.js b/js/ui/components/VideoModal.js index 825f9c9e..dbdbf833 100644 --- a/js/ui/components/VideoModal.js +++ b/js/ui/components/VideoModal.js @@ -3006,7 +3006,10 @@ export class VideoModal { } handleEmbedRequest() { - this.dispatch("action:embed", { video: this.activeVideo }); + // ModalManager listens for "video:embed" (it opens EmbedVideoModal). The + // previous "action:embed" name had no listener, so the embed button did + // nothing — the event was dispatched into the void. + this.dispatch("video:embed", { video: this.activeVideo }); } handleCreatorNavigation() { diff --git a/tests/video-modal-zap.test.mjs b/tests/video-modal-zap.test.mjs index 005c1ced..20f0df54 100644 --- a/tests/video-modal-zap.test.mjs +++ b/tests/video-modal-zap.test.mjs @@ -1005,4 +1005,27 @@ const { VideoModal } = await import("../js/ui/components/VideoModal.js"); ); })(); +(() => { + // Regression (#18): the Embed button dispatched "action:embed", but ModalManager + // listens for "video:embed" (which opens EmbedVideoModal) — so embed did nothing. + // handleEmbedRequest must dispatch the name the manager actually listens for. + const modal = new VideoModal({ document: documentStub, setGlobalModalState: noop }); + modal.activeVideo = { id: "vid-embed", pubkey: "p".repeat(64) }; + + let embedDetail = null; + modal.addEventListener("video:embed", (event) => { + embedDetail = event?.detail || null; + }); + let staleFired = false; + modal.addEventListener("action:embed", () => { + staleFired = true; + }); + + modal.handleEmbedRequest(); + + assert.ok(embedDetail, 'embed must dispatch "video:embed" (the listened name)'); + assert.equal(embedDetail.video?.id, "vid-embed", "carries the active video"); + assert.equal(staleFired, false, 'must not use the dead "action:embed" name'); +})(); + process.exit(0);