Skip to content

Accordion Panel: Padding is also shown in accordion with closed panels #80776

Closed

Description

@hanneslsm

Description

When a accordion panel has a padding in the theme.json applied, this padding is also shown even when the accordion is closed.
I think the panel and the panels spacing should only show, when the accordion is open. Otherwise the panels paddings effects the spacing between the accordion headings and items.

Step-by-step reproduction instructions

  1. Create a accordion with multiple items
  2. Make sure that there is no spacing between the accordion items
  3. Add padding to the accordion panel
  4. Watch the spacing of the items change, even though the panel should be hidden

Screenshots, screen recording, code snippet

Image

Environment info

  • WP 7.1
  • GB 23.6.0

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. iamtakashi commented on Jul 30, 2026

    @iamtakashi

    Root cause: the server never renders the closed state. The button gets aria-expanded="false", but the panel's data-wp-bind--hidden="state.isHidden" isn't evaluated server side (derived state in the view module, nothing seeded via wp_interactivity_state()), so closed panels render open until hydration. Theme-side mitigations can't fully compensate: the padding is an inline style, so stylesheet overrides lose without !important.

    Workaround: use a spacer inside the panel (with blockGap: 0) instead of panel padding; content is hidden when closed, padding isn't.

    Fix direction: seed the state so hidden is in the SSR output, which also fixes the flash of open panels on load.

  2. andrewkathart commented on Aug 25, 2026

    @andrewkathart

    What's the status of this, anyone know?

    It's happened to pretty much all my sites using the native accordion block, after updating WordPress to version 7.1. It's not critical, but would be nice to not have to update each site individually.

  3. youknowriad commented on Oct 19, 2026

    @youknowriad
    Contributor

    Thanks for the report, @hanneslsm! I tested on WordPress 7.1.2 with Gutenberg trunk (built 2026-10-16). With 40px padding on the Accordion Panel, closed panels now render with 0 padding and 0 height on the front end, and the padding comes back only when a panel opens. The fix is #81782, which resets padding, borders and shadows on .wp-block-accordion-panel[hidden]. The separate issue of panels rendering open before hydration is tracked in #81869. Closing this, but please reopen with steps if you still see the gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] AccordionAffects the Accordion Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions