mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-03 03:12:31 +00:00
video-modal: fix Embed button doing nothing (wrong event name)
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 <[email protected]>
This commit is contained in:
1 parent
deabac064b
commit
a5b284682c
2 files changed
+27
-1
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
Reference in new issue
Block a user