Skip to content

fix(lightbox): load shell and JS as core so fullscreen is reliable#1982

Merged
markdumay merged 1 commit into
mainfrom
feat/lightbox-always-core
Jul 5, 2026
Merged

fix(lightbox): load shell and JS as core so fullscreen is reliable#1982
markdumay merged 1 commit into
mainfrom
feat/lightbox-always-core

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

Summary

The lightbox <dialog> shell and its JS rendered unreliably. On a page using a fullscreen/lightbox shortcode the trigger button rendered but the dialog + JS were frequently absent, so clicking did nothing — and it varied build to build.

Root cause: the shell (assets/lightbox.html) and the optional-scripts pass gated on the lightbox module dependency that shortcodes register via AddModulepage.Scratch "dependencies" during content rendering. Per Hugo's own docs a value set that way is "indeterminate until Hugo renders the page content", so the head/shell consumers that read it too early saw it only intermittently.

Fixes #1981.

Change

Treat the lightbox as core theme furniture rather than an opt-in module:

  • render the <dialog> shell on every page (inert until a [data-lightbox-trigger] is clicked);
  • flip the module to integration = "core" so its JS always bundles into the core set;
  • drop the now-vestigial AddModule call from assets/lightbox-trigger.html.

Nothing reads the indeterminate dependencies channel anymore, so any [data-lightbox-trigger] works without per-page modules: front matter.

Verification

Built the exampleSite against this branch and drove the lightbox-demo page (front matter is title only — the previously-failing config) with Playwright:

  • shell present on the demo page and on pages with no lightbox usage (always-render);
  • showModal/lightbox JS present in core.bundle.*.mjs (loaded everywhere);
  • dialog opens in the top layer (:modal) with the source node cloned in and the nested trigger stripped;
  • close button + Esc + backdrop-close intact.

Notes

The lightbox shell and its JS were gated on a `lightbox` module
dependency that shortcodes register via AddModule during content
rendering. Per Hugo's docs a value set that way is "indeterminate
until Hugo renders the page content", so the head/footer templates
that read it — the shell include and the optional-scripts pass — saw
it only intermittently. Pages using a fullscreen/lightbox shortcode
rendered the trigger button but often not the dialog or its JS.

Make the lightbox core theme furniture: render the <dialog> shell on
every page and bundle its JS into the core set. Any
[data-lightbox-trigger] now works without per-page module
registration. Drop the now-vestigial AddModule call from the trigger
partial.
@netlify

netlify Bot commented Jul 5, 2026

Copy link
Copy Markdown

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit b1e399f
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6a49e0dae96e810008b6f2a5
😎 Deploy Preview https://deploy-preview-1982--gethinode-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@markdumay markdumay enabled auto-merge July 5, 2026 04:45
@markdumay markdumay merged commit 775da51 into main Jul 5, 2026
15 checks passed
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.16.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@markdumay markdumay deleted the feat/lightbox-always-core branch July 5, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lightbox dialog renders unreliably: shortcode-registered module dependency is render-order-dependent

1 participant