Automattic / Automattic/blocks-engine
Preserve non-empty positioned badge leaves during RichText lowering
- Dominant language
- PHP
- Stars
- 14
- Forks
- 2
- Avg merge
- 2h 10m
- Merged PRs (30d)
- 561
Description
## Problem
A non-empty styled inline badge can disappear when lowered under a positioned visual wrapper, even though sibling badges with the same shape render.
In immutable fixture `20-switchback-woocommerce-extra-hard`, the fourth featured-kit card contains an absolutely positioned wrapper with `New`. The source badge box is `44.25 x 23.875` at `x=971, y=2245.66`; the candidate omits it, producing a `44 x 24` / `1,041px` missing-element region. Other `.badge--bestseller`, `.badge--sale`, and `.badge--staff-pick` instances survive.
## Owner
PHP transformer styled-inline-leaf lowering, around `HtmlTransformer::visualTextWrapperBlockFromElement()` and RichText inline handling. This is not #758, which covered empty visual leaves.
## Acceptance
- Preserve non-empty styled inline text leaves under positioned wrappers.
- Retain safe classes and authored background/color/padding/typography semantics.
- Do not synthesize text for genuinely empty visual leaves.
- Sibling badge variants follow one generic path with deterministic output.
- Add positive positioned non-empty and negative empty-leaf contracts.
- Fixture 20 renders all four badges without fixture changes.
## AI assistance
OpenAI gpt-5.6-terra via OpenCode and a general OpenCode subagent measured immutable visual/DOM evidence and isolated one non-empty positioned badge omission. Chris Huber directed the investigation and remains responsible for the issue and resulting change.
Contributor guide
Research direction
Start with HtmlTransformer::visualTextWrapperBlockFromElement() and the RichText inline handling described in the issue. Reproduce the immutable fixture 20-switchback-woocommerce-extra-hard and inspect the fourth featured-kit card. Add positive positioned non-empty and negative empty-leaf contracts; done means all four badges render with their safe classes and authored styles, without synthesizing empty text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100