fix(lightbox): load shell and JS as core so fullscreen is reliable#1982
Merged
Conversation
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.
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
🎉 This PR is included in version 2.16.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thelightboxmodule dependency that shortcodes register viaAddModule→page.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:
<dialog>shell on every page (inert until a[data-lightbox-trigger]is clicked);integration = "core"so its JS always bundles into the core set;AddModulecall fromassets/lightbox-trigger.html.Nothing reads the indeterminate
dependencieschannel anymore, so any[data-lightbox-trigger]works without per-pagemodules:front matter.Verification
Built the exampleSite against this branch and drove the
lightbox-demopage (front matter istitleonly — the previously-failing config) with Playwright:showModal/lightbox JS present incore.bundle.*.mjs(loaded everywhere);:modal) with the source node cloned in and the nested trigger stripped;Notes
fix:→ patches to v2.16.1.dependencies-scratch indeterminacy is latent for the<head>CSS/JS consumers (head/head.html, critical/functional passes). They're safe today because modules are conventionally declared in front matter, but a.Content-noop or a doc caveat would harden them — see Lightbox dialog renders unreliably: shortcode-registered module dependency is render-order-dependent #1981.