Closed-state normalizer strips opacity:0 from text without a reveal gate, exposing hover/active-only state labels

Open
#6,316 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php, playwright, wordpress
Domain
backend, web-dev

Research direction

Start with ClosedStateNormalizer.php and StyleResolver.php, especially strip(), repairFor() and sourceRevealProperties(); then inspect the existing regression tests for closed-state normalization. Use the reduced HTML fixture with studio create --from <fixture>.html and check the imported label’s computed opacity in Playwright. Done means the import preserves opacity 0 when its reveal is CSS-only, with a regression fixture covering the case.

Written by the indexing model from the issue text.

Description

Summary

ClosedStateNormalizer removes opacity:0 from any text-bearing element, whether or not the source has a way to reveal it. The import then adds opacity:1!important;transform:none!important. A state label that the source hides at rest becomes permanently visible. Common examples are a playlist thumbnail's "Now Playing" overlay, which shows only on :hover or on the active item.

display:none, visibility:hidden and height/max-height:0 collapses are only stripped when sourceRevealProperties() finds a matching reveal rule or an aria-controls target. opacity:0 has no such gate.

This is related to #5198, but it is not the same case. The fixes for #5198 (#5228, #5264) exempt media-player control chrome (a role="group" "video controls" region with a seek range and play/mute buttons). The label here is ordinary text with no player controls around it, so that exemption does not apply.

Reduced fixture

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Playlist</title>
<style>
.label{opacity:0}
.item:hover .label{opacity:1}
</style>
</head>
<body>
<div class="item"><p>First video</p><div class="label">Current item</div></div>
</body>
</html>

To reproduce, run studio create --from <fixture>.html and open the front page.

Observed

Playwright computed style for the Current item text at 1440px:

element opacity
source fixture (file://) div.label 0
imported WordPress page p.label 1

The emitted theme CSS (engine-support-after-author-*.css and editor-static-state-*.css) contains:

:root .label{opacity:1!important;transform:none!important}
  • Dropping the .item:hover .label{opacity:1} rule changes nothing: the output is identical. The hover rule is kept in the fixture only because it shows the label is meant to stay hidden at rest. Its reveal is plain CSS, which survives import unchanged and would still work in WordPress if the base opacity:0 were kept.
  • On the real-world page this came from (a site-builder video gallery), every thumbnail showed a centered "Now Playing" label. In the source, that label is aria-hidden="true" and is revealed only by .item.is-active .label, .item.is-active:hover .label {opacity:1}. Both the live page and the capture computed opacity:0. The import forced opacity:1. So the capture is correct and the problem happens during materialization.

Root cause

Expected

  • opacity:0 on content is kept, just like display:none or visibility:hidden, unless the reveal really depends on script that the import removes. If the only reveal is a CSS pseudo-class such as :hover or :focus-within, the closed state should be kept, because that reveal still works after import.
  • aria-hidden="true" text should also be a strong signal that the element is a decorative state indicator, not editorial content.
  • A regression fixture built from the reduced case should fail on trunk and pass with the fix: .label computes opacity:0 on the imported page.

Seen with Static Site Importer 1.34.104 and blocks-engine trunk ad346db3e39.

Reduced and filed with AI assistance (Claude, via coding agent).

Dominant language
PHP
Stars
28
Forks
5
Avg merge
2h 59m
Merged PRs (30d)
942

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/blocks-engine

All issues in Automattic/blocks-engine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.