Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving too quickly between pages on the popped-out "speaker notes" window resets to non-notes view #2004

Open
fw-immunant opened this issue Apr 18, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@fw-immunant
Copy link
Collaborator

To reproduce, tap left and right a couple times while the speaker notes window is focused after popping it out into its own window. It will revert to showing a second copy of the course material, as if the speaker notes window had been closed.

@fw-immunant fw-immunant added the bug Something isn't working label Apr 18, 2024
@mgeisler
Copy link
Collaborator

Thanks for logging this! The speaker notes system is quite rudimentary and it could benefit from someone with better JavaScript skills than me giving it an overhaul.

@randomPoison
Copy link
Collaborator

I've found that navigating at all in the speaker notes immediately breaks the connection between the speaker notes and the main window. I'm assuming this is the same issue that @fw-immunant ran into here.

@djmitche
Copy link
Collaborator

I've seen that as well.

@michael-kerscher
Copy link
Collaborator

I can also reproduce this reliably by clicking into the notes and go to the right. The speaker notes view is now turning into the regular slide view".
Moving left does break the connection to the regular slides but stays in the speaker notes view - it is independent from the regular slides though

Interesting behavior: moving left or right has a different effect

@michael-kerscher
Copy link
Collaborator

michael-kerscher commented Feb 7, 2025

I found the issue with the "next" navigation and created a pull request.

There is an additional issue causing the break:

popup.onload = () => {
popup.onbeforeunload = () => {
setState("inline-open");
applyState();
};

This triggers on any unload (e.g. access next slide) of the (speaker notes) page - which means prev+next navigation events.

There is a workaround that tries to avoid acting on this, but depending on the the sequence and timing of events this still might break

// When navigating to another page, we see two state changes in rapid
// succession:
//
// - "popup" -> "inline-open"
// - "inline-open" -> "popup"
//
// When the page is closed, we only see:
//
// - "popup" -> "inline-open"
//
// We can use a timeout to detect the difference. The effect is that
// showing the speaker notes is delayed by 500 ms when closing the
// speaker notes window.
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(applyState, 500);
break;

michael-kerscher added a commit that referenced this issue Feb 8, 2025
Change this selector to use the ~= selector to test if a white space
separated word "prev" or "next" is contained

Fixes a speaker notes bug that did not allow going to the next slide in
the speaker notes.
The reason for that is that the "rel" attribute contained "prev"
respective "next prefetch".

See:
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#attrvalue_2

This fixes part of #2004 when going to the right (containing
"prefetch").
@michael-kerscher
Copy link
Collaborator

To add some thoughts on this: We need some mechanism for the slides to discover that the speaker notes are closed. Currently this is done by signaling back to the slides when the speaker notes close (with the beforeunload event - that triggers for any unload, be it window close or some full navigation from the current page).

Options that might be viable and need some discussion:

  • quick&dirty: use the current mechanism (see above) that waits for some time but clearly match the events. It currently does not take into account the current state when clearing the timeout (quick navigation can break this with a sequence of "inline-popup" (due to beforeunload event, then speaker notes setup sends "popup" (canceling the timeout) and regular page sends either the "inline-popup" or "inline-closed" because of this toggling (this seems to trigger a toggle on page load if I see this correctly)
    // Create speaker notes.
    notes.addEventListener("toggle", (event) => {
    setState(notes.open ? "inline-open" : "inline-closed");
    });
    (this is likely the least effort, a bit brittle depending on timing)
  • A ping-pong style polling mechanism based on BroadcastChannels where the slides ask regularly (e.g. 500ms) "is there an active speaker notes window" (ping) and the speaker notes answer on that channel with a "yes" (pong). Once that pong is not sent, the state is set to inline-open (this seems like the most reliable way and might even recover if a speaker-notes window reappears (think Ctrl+Shift+T -> reopen accidentally closed tab).
  • Add some mechanism to remove the beforeunload handler when a navigation event happens (more difficult but possible, create a function that is called when click is registered + use that function also when the current_page key of the localstorage changes. This could be brittle due to the many ways a navigation event could happen (not only click, but javascript or the back/prev functionality)

@djmitche
Copy link
Collaborator

I think that popout is a WindowProxy object, so it should be possible for the main page to poll that object.

@michael-kerscher
Copy link
Collaborator

michael-kerscher commented Feb 10, 2025

Yes it is, but it is destroyed on navigation attempts like switching to a different slide as far as I understand. I also thought about using that to figure out if popout.closed is true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants