fix(slideshow): address review — audience ignores local nav keys, no title flash

- Audience mode ignores Arrow/Space/Backspace (window + forwarded iframe
  paths): local nav silently de-synced the audience view from the
  presenter until the next BroadcastChannel goto. F/fullscreen unchanged.
- present wrapper titles both tabs from ?mode= in one script instead of
  defaulting the audience tab to '— Presenter' and correcting it later,
  so Meet's tab picker never sees the wrong role.
- Note in the iframe text-entry test that happy-dom is single-realm (it
  asserts the guard fires, not cross-realm semantics).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Vance Ingalls
2026-07-02 10:09:04 -07:00
co-authored by Claude Fable 5
parent 4c67bf7573
commit 5e1d643603
3 changed files with 53 additions and 6 deletions
+10 -6
View File
@@ -193,13 +193,17 @@ function buildPresentPage(projectName: string, islandJson: string): string {
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${escHtml(projectName)} — Presenter</title>
<title>${escHtml(projectName)}</title>
<script>
// Retitle the audience tab so the two tabs are distinguishable in the
// browser tab strip and in Meet's "Share a tab" picker.
if (new URLSearchParams(location.search).get("mode") === "audience") {
document.title = ${JSON.stringify(projectName).replace(/</g, "\\u003c")} + " — Audience";
}
// Role suffix distinguishes the two tabs in the tab strip and in Meet's
// "Share a tab" picker. Set from ?mode= for BOTH roles (rather than a
// static "— Presenter" default) so the audience tab never flashes the
// wrong role before this script runs.
document.title =
${JSON.stringify(projectName).replace(/</g, "\\u003c")} +
(new URLSearchParams(location.search).get("mode") === "audience"
? " — Audience"
: " — Presenter");
</script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
@@ -713,6 +713,37 @@ describe("<hyperframes-slideshow> presenter mode", () => {
el.remove();
});
it("audience mode: ignores local nav keys (channel-driven only)", () => {
// Local arrows in the audience view would silently de-sync it from the
// presenter until the next goto; nav keys are ignored in audience mode.
const el = document.createElement("hyperframes-slideshow") as any;
el.setAttribute("mode", "audience");
document.body.appendChild(el);
let nexts = 0;
el.__setControllerForTest({
next: () => {
nexts++;
},
prev: () => {},
goToSlide: () => {},
onChange: () => () => {},
counter: { index: 1, total: 3 },
breadcrumb: [{ id: "main", label: "Main deck" }],
currentSlide: { hotspots: [] },
nextSlide: null,
get position() {
return MAIN_POS;
},
});
el.focus();
window.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight" }));
window.dispatchEvent(new KeyboardEvent("keydown", { key: " " }));
expect(nexts).toBe(0);
el.remove();
});
it("audience mode: mirrors a branch position too (full sequenceId forwarded to syncTo)", async () => {
const presenterChannel = new BroadcastChannel(slideshowChannelName());
const { el, getLastSync } = makeAudienceEl();
@@ -1071,6 +1102,9 @@ describe("<hyperframes-slideshow> presenter mode", () => {
// Text-entry targets inside the iframe must NOT navigate (duck-typed guard —
// iframe-realm elements are not instanceof this realm's classes).
// NOTE: happy-dom shares one realm across frames, so this asserts the guard
// fires — it cannot distinguish duck-typing from instanceof; only a real
// browser exercises the cross-realm case.
const doc = iframe.contentDocument;
if (doc) {
const input = doc.createElement("input");
@@ -821,6 +821,15 @@ export class HyperframesSlideshow extends HTMLElement {
// from the composition iframe, whose elements are instances of the IFRAME
// realm's classes — instanceof against this realm's would never match.
if (isTextEntryTarget(e.target)) return;
// The audience view follows the presenter over BroadcastChannel; local nav
// keys would silently de-sync it until the presenter's next goto. Ignore
// them entirely in audience mode (F/fullscreen still works below).
if (
this.resolveMode() === "audience" &&
(e.key === "ArrowRight" || e.key === "ArrowLeft" || e.key === " " || e.key === "Backspace")
) {
return;
}
const active = document.activeElement;
// With focus inside the composition iframe, the top document's activeElement
// is the <iframe> itself — contained by this element, so `focused` stays true