Problem/Motivation

When JavaScript is disabled, WET lightbox/modal content (e.g. .mfp-hide) is expected to be displayed as standard inline content using the noscript.css fallback.

However, in the current WxT implementation, the <noscript> stylesheet is injected via hook_page_attachments() using html_head, which results in the following render order:

<head>
  <noscript><link rel="stylesheet" href="/libraries/wet-boew/css/noscript.css"></noscript>
  ...
  <link rel="stylesheet" href="...theme.css">
  <link rel="stylesheet" href="...wxt.css">
</head>

Because of this, rules in noscript.css (e.g. .mfp-hide { display: block !important; }) are overridden by later-loaded CSS that includes:

.mfp-hide {
  display: none !important;
}

As both rules use !important, the later-loaded CSS takes precedence, causing modal content to remain hidden when JavaScript is disabled.

Steps to reproduce

Add a page with a modal, HTML can be taken from here - https://wet-boew.github.io/v4.0-ci/demos/overlay/overlay-en.html

Disable JavaScript in your browser and load the page, notice the modal is not displayed under the link to trigger it.

Proposed resolution

Move the <noscript> stylesheet injection out of html_head and render it after <css-placeholder> in html.html.twig.

Comments

smulvih2 created an issue. See original summary.

smulvih2’s picture

Status: Active » Needs review
StatusFileSize
new631 bytes
new1.81 KB

Patches attached for wxt_library and wxt_bootstrap to fix the issue. Since html_head is printed in html.html.twig above all CSS, we need to add the no-script under the CSS palceholder. Also can't include noscript in CSS placeholder since it needs to be wrapped in a noscript tag, so using hook_preprocess_html() for this. With the patches applied, the noscript element is added below all CSS, same as on Canada.ca.

smulvih2’s picture

Pushed fix to both repos for 10.6.x and 11.3.x.

smulvih2’s picture

Status: Needs review » Fixed

New versions pushed for wxt_library and wxt_bootstrap; 11.3.1 and 10.6.1 for both.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.