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

未关闭
#6,316 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php, playwright, wordpress
领域
backend, web-dev

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
PHP
星标
28
派生
5
平均合并
2 小时 59 分钟
30 天内合并 PR
942

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Automattic/blocks-engine 的其他 Issue

查看 Automattic/blocks-engine 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。