Pinned button link (absolute, inset:0) loses authored width:max-content: generated width:100%!important clips the label
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
Línea de trabajo
Empieza en php-transformer/src/HtmlToBlocks/Style/GeneratedBlockStyleProjector.php, leyendo la rama de dimensionamiento del contenedor del botón y sourceControlPinsToItsWrapper() junto con las comprobaciones del ancho definido que se mencionan en el issue. Usa B-button-max-content.html como fixture reducido y verifica que la regla generada conserve un ancho distinto de auto y mantenga la altura fijada; se considera terminado cuando el enlace importado sigue midiendo unos 186px de ancho y la etiqueta completa aparece sobre su fondo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
A source button link that is absolutely positioned with inset:0 inside a small sized wrapper, but also declares width:max-content; min-width:100%, is wider than its wrapper in the source. It sizes to its label. After import it becomes core/buttons > core/button, and a generated rule forces the link to width:100%!important. The link shrinks to the wrapper's width, and the label overflows on both sides. Light label text that overflows the button background disappears against the page, so the visible text is clipped. For example, "Get in touch with the team" renders as "n touch with the".
Owning stage: WordPress materialization (generated block style projection for lowered core/button).
Reduced fixture
B-button-max-content.html (standalone, CSS inline):
<!doctype html><html><head><meta charset="utf-8"><title>Button fixture</title><style>
body{margin:0;font-family:sans-serif}
.box{position:relative;width:110px;height:40px;margin:40px}
.btn{box-sizing:border-box;display:flex;align-items:center;justify-content:center;width:max-content;min-width:100%;background:#5d1ff2;color:#fff;white-space:nowrap}
[data-variant] .box .btn{position:absolute;inset:0}
</style></head><body><main><div data-variant="solid"><div class="box"><a class="btn" href="/about/">Get in touch with the team</a></div></div></main></body></html>
The [data-variant] ancestor in the positioning rule matters. It sends the rule through the attribute-ancestry selector projection, which keeps position:absolute; inset:0 on .wp-block-button__link, matching the source. The same rule written as a plain .box .btn moves position:absolute onto the .wp-block-buttons wrapper, without its inset. That wrapper then shrink-wraps to the label, which hides this bug by accident. Large captured sites hit the first path because their author rules carry attribute-gated ancestors.
Observed
Viewport 1280px, Chromium (Playwright), measured with getBoundingClientRect():
| Wrapper width | Link width | Label text extent (x) | Link extent (x) | |
|---|---|---|---|---|
| Source | 110 | 185.9 (max-content) | 40 → 225.9 | 40 → 225.9 |
| Imported | 110 | 110 | 2.1 → 187.9 | 40 → 150 |
Imported block structure: core/group.box > core/buttons > core/button > a.wp-block-button__link (position:absolute; inset:0, from the projected author rule).
Winning generated rule:
.blocks-engine-control-<hash>-0.blocks-engine-control-<hash>-0>.wp-block-button__link{width:100%!important;height:100%!important;border-radius:0!important;text-align:start!important}
It overrides the projected author declaration width:max-content;min-width:100% on the same link.
The same thing happened on a full captured site: a 109px × 40px button wrapper whose link was 196px wide in the source became 109px after import.
Root cause
php-transformer/src/HtmlToBlocks/Style/GeneratedBlockStyleProjector.php (trunk ad346db3), in the button carrier sizing chain:
} elseif ( self::sourceControlPinsToItsWrapper($sourceDeclarations) ) {
// The source control takes its box from a sized wrapper by pinning
// to every edge. ...
$outerWrapperDeclarations[] = 'height:100%';
$wrapperDeclarations[] = 'height:100%';
$declarations[] = 'width:100%!important';
$declarations[] = 'height:100%!important';
}
sourceControlPinsToItsWrapper() (line ~631) only checks position:absolute and inset:0 (or all four edges set to 0). In CSS an absolutely positioned box with left:0; right:0 only fills its containing block when width is auto. If width is set to anything else, the box is over-constrained: right is ignored and the authored width wins. Here the source declares width:max-content and min-width:100%, so the box is at least as wide as the wrapper and grows to its label. The branch never checks $hasAuthoredWidth or the authored width value (both are computed earlier in the same method, line ~267). It emits width:100%!important, which turns "at least the wrapper" into "exactly the wrapper".
Expected
When the source control declares a non-auto width (for example max-content, fit-content, or a length), the pins-to-wrapper branch should not force width:100%!important. Keep the authored width and min-width:100%. The pinned height:100% behavior can stay. The imported link in the fixture should measure about 186px wide and show the full label on the button background, as in the source.
Reduced and filed with AI assistance (Claude, via coding agent).
- Lenguaje dominante
- PHP
- Estrellas
- 28
- Forks
- 5
- Merge medio
- 2 h 59 min
- PR fusionados (30 d)
- 942
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Automattic/blocks-engine
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/blocks-engine#4943 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/blocks-engine#4942 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Automattic/blocks-engine#4921 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Automattic/blocks-engine#775 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
Automattic/blocks-engine#6325 ·
Los mantenedores suelen responder en 1 día
Todos los issues de Automattic/blocks-engine
Issues similares
-
kind/enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[remove-resource] Delete Open Course Hub, Open Multicourse Hub, and Learn2 with GitSync skeletonsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
omeka/plugin-ExhibitBuilder#160 ·