Skip to content

Restate an accordion trigger's box that core cannot save - #1872

Merged
chubes4 merged 1 commit into
trunkfrom
fix/accordion-toggle-presentation
Sep 16, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
fix/accordion-toggle-presentation

Conversation

@chubes4

@chubes4 chubes4 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Problem

core/accordion-heading saves its own toggle with a fixed class and nothing else:

<button type="button" class="wp-block-accordion-heading__toggle">

A source trigger's classes are therefore dropped, and every author rule addressing them is left with nothing to match. A trigger that stated its own vertical padding collapses onto the destination theme's defaults:

<!-- source -->
<button class="flex flex-1 items-center justify-between py-4 text-sm font-medium"></button>

py-4 is 16px top and bottom. Losing it cost ~14px per row, and an imported five-row FAQ ran 70px short of its source at every viewport — the single remaining geometry gap on the site this was found on, at both 1440px and 390px.

Fix

Carry the resolved trigger box as generated CSS keyed on a marker the heading holds:

.wp-block-accordion-heading.blocks-engine-accordion-toggle-<hash>>.wp-block-accordion-heading__toggle{
  display:flex;align-items:center;justify-content:space-between;padding-top:1rem;padding-bottom:1rem
}

Attributes cannot go on the toggle itself — that would diverge from core's save shape and invalidate the block. core/details already resolved the same problem for the same reason (disclosureSummaryMarker), so the declaration side is shared rather than duplicated: disclosureControlCarriedCss() now serves both, and the two callers differ only in their selector and marker prefix.

Triggers resolving to the same box share one marker and emit one rule. A trigger with no resolved box of its own carries no marker.

Verification

Re-imported the source site and measured every section against it.

1440px — total page height 5360 vs 5360, delta 0:

section source WP
hero 1000 @ 0 1000 @ 0
benefícios 705 @ 1000 705 @ 1000
sobre mim 914 @ 1705 914 @ 1705
como funciona 564 @ 2619 564 @ 2619
formação 826 @ 3183 826 @ 3183
dúvidas (FAQ) 489 @ 4009 489 @ 4009
CTA 456 @ 4498 456 @ 4498

390px — all seven sections match on height and offset.

Every section now matches on both height and y-offset at both viewports. Import stays clean: quality pass, 0 fallbacks, 0 invalid blocks.

  • New tests/unit/accordion-toggle-presentation.php — 9 assertions covering the marker, core's save shape staying byte-exact, marker reuse, rule de-duplication, and an unmarked bare trigger.
  • tests/unit/closed-details-fixed-overlay.php still green, covering the shared declaration path.
  • composer test:canonical, composer test:parity (311 fixtures), composer test:packaging all green.

Follow-up, not in scope

Core renders the toggle icon as a + glyph where the source used a chevron SVG. That is a core-owned glyph inside a now-correct box, and is worth handling separately.

AI assistance disclosure

Investigated and implemented with Claude Sonnet 4.6 via opencode. The model measured imported-versus-source section geometry with Playwright to isolate the 70px gap to the accordion trigger, found the existing core/details precedent, then wrote the fix and its tests. All output was reviewed before submission.

core/accordion-heading saves its own `<button>` with a fixed class and no
others, so a source trigger's classes are dropped and every author rule
addressing them is left with nothing to match. A trigger that stated its
own vertical padding collapsed onto the destination theme's defaults and
every row in the accordion lost that height — an imported FAQ ran 70px
short of its source at every viewport.

Carry the resolved trigger box as generated CSS keyed on a marker the
heading holds, the way core/details already restates its summary.
Attributes cannot go on the toggle itself: that would diverge from core's
save shape and invalidate the block.

The declaration side is shared with the details path, which resolved the
same problem for the same reason.
@chubes4
chubes4 merged commit 3a8f1d8 into trunk Sep 16, 2026
10 checks passed
@chubes4
chubes4 deleted the fix/accordion-toggle-presentation branch September 16, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant