Skip to content

fix(editor-modal): attach overlay to topmost same-origin window#59

Merged
ignaciogros merged 4 commits into
mainfrom
fix/editor-modal-host-window
May 13, 2026
Merged

fix(editor-modal): attach overlay to topmost same-origin window#59
ignaciogros merged 4 commits into
mainfrom
fix/editor-modal-host-window

Conversation

@erseco
Copy link
Copy Markdown
Collaborator

@erseco erseco commented Apr 29, 2026

Summary

Mirrors the editor-modal half of exelearning/mod_exeweb#46.

In amd/src/editor_modal.js the overlay was appended to the current frame's document.body. When the Edit button was clicked from a small embedded frame (e.g. a popup-mode launcher), the modal got rendered inside that cramped frame and the Save / Close buttons ended up out of reach — described in mod_exeweb#43 as the dialog "stuck at the bottom and hard to close".

This walks the parent chain to the topmost same-origin window before mounting, so the overlay always covers the full viewport. Cross-origin parents fall back to the current window.

Note: the missing-Edit-button part of mod_exeweb#43 does not reproduce here — mod/exescorm/view.php already renders the Edit button before launching the popup window, regardless of popup setting. Only the modal-positioning fix is needed.

Test plan

  • Open an exescorm activity with Display = In a new window (popup) and the embedded type. Confirm the Edit button appears on the parent view and the modal opens full-viewport.
  • Confirm Save / Close buttons in the modal are reachable and Escape still closes it.
  • Confirm Display = current window still behaves as before.

Refs exelearning/mod_exeweb#46
Refs exelearning/mod_exeweb#43


Moodle Playground Preview

The changes in this pull request can be previewed and tested using a Moodle Playground instance.

Preview in Moodle Playground

⚠️ The embedded eXeLearning editor is not included in this preview. You can install it from Modules > eXeLearning SCORM > Configure using the "Download & Install Editor" button. All other module features (ELPX upload, viewer, preview) work normally.

@erseco erseco requested a review from ignaciogros April 29, 2026 16:32
@erseco erseco self-assigned this Apr 29, 2026
Copy link
Copy Markdown
Collaborator

@ignaciogros ignaciogros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When entering a SCORM package in popup mode by clicking the “Enter” button:

  • The popup window does not take up the full screen, but it can be resized. That seems correct.
  • The “Edit activity” button does not appear in the parent page.
  • If the SCORM is opened in “Current window” mode, it works correctly.

Tested in Moodle 4.5.10 (Build: 20260216) with https://github.com/erseco/alpine-moodle

@erseco
Copy link
Copy Markdown
Collaborator Author

erseco commented May 9, 2026

I've force-pushed the sibling PR on mod_exeweb (exelearning/mod_exeweb#46) to address @ignaciogros' review. There the root cause was the In frame (HTML4 frameset) mode: dropping it removes in one go the modal stuck at the bottom, the missing Edit button, and the broken fullscreen, because Embed already does the same with an <iframe>.

In this PR (mod_exescorm) the situation is different:

  • There is no In frame mode; popup mode opens a separate window via window.open(), not a nested frameset, so the topmost-window logic this PR introduces doesn't rest on the same justification as in mod_exeweb.
  • The review concern ("the Edit activity button does not appear in the parent page") seems to happen after the popup launches, when view.js (exescormload) replaces #intro with the popuplaunched link and hides #exescormviewform and #toc. The Edit button is rendered in view.php right after #intro, outside form/toc, so it shouldn't disappear; I suspect a side effect of load ordering or the theme, but I haven't reproduced it locally yet.

Before I touch more code here I'd like to confirm with you:

  1. Should I keep the topmost-window logic in editor_modal.js (it covers, for example, embeds inside theme iframes), or drop it so this plugin stays symmetric with mod_exeweb?
  2. The Edit button missing in popup mode — did you see it on an activity with exescormtype = embedded / .elpx, or also with online / local types? That would help isolate whether the view.php conditional (exescormtype === EMBEDDED || $iselpx) is filtering too much, or whether it's the later view.js manipulation.

When the embedded eXeLearning editor modal is opened from inside a
small frame (e.g. a popup-mode launcher or any embedded iframe), the
overlay was previously appended to that cramped frame's body. The
result was a dialog "stuck at the bottom" of the frame with the
Save/Close buttons rendered out of reach.

Walk up the window chain to the topmost same-origin window before
mounting, so the overlay always covers the full viewport. Cross-origin
parents fall back to the current window.

Mirrors exelearning/mod_exeweb#46.
@erseco erseco force-pushed the fix/editor-modal-host-window branch from 4786804 to d1e570f Compare May 9, 2026 12:45
Copy link
Copy Markdown
Collaborator

@ignaciogros ignaciogros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @erseco,

I used the "Uploaded package version", selecting a .zip file from my device instead of creating it with the plugin.

I still get the same results:

  • The popup window does not take up the full screen, but it can be resized. I think that's enough. I can improve that later if you want.
  • The "Edit activity" button does not appear in the parent page.
  • If the SCORM is opened in “Current window” mode, it works correctly. In that case, apart from the navigation problems commented in #63, the only thing to review is this confirm message displayed when clicking the "Save to Moodle" button, but I don't know if it can be avoided:
Image

About your questions:

  • Unless you've tested it and you think it's not necessary, I think that we should keep editor_modal.js. Maybe we can review that later, after fixing other important issues.
  • The "Edit with eXeLearning" button is only missing with the "Uploaded package" type.

Thank you!

@ignaciogros ignaciogros merged commit 365e755 into main May 13, 2026
1 check passed
@ignaciogros ignaciogros deleted the fix/editor-modal-host-window branch May 13, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants