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

Aperta
#6,316 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, playwright, wordpress
Ambito
backend, web-dev

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
PHP
Stelle
28
Fork
5
Merge medio
2h 59m
PR unite (30g)
942

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Automattic/blocks-engine

Tutte le issue di Automattic/blocks-engine

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.