Skip to content

[v4] Document controls: empty __icon-buttons wrapper doubles the gap before Save #19395

Open

Description

@VeiaG

Describe the Bug.

DocumentControls always renders <div className="doc-controls__icon-buttons">, even when none of its children render (live preview toggler, preview button, schedule publish button). The wrapper is still a flex item of .doc-controls__controls, which has gap: var(--spacer-2). So when it's empty, the space between whatever comes before it and the Save / Publish button doubles: 8px + 0px + 8px = 16px.

You can see this with any admin.components.edit.beforeDocumentControls component on a collection that has no live preview, no admin.preview and no scheduled publish. The custom control sits noticeably further from Save than the other controls in the row are from each other.

Expected: the gap before Save is 8px whether or not the icon buttons render.

Without icon buttons (bug, 16px):

Image

With admin.preview (8px + 8px) :

Image

Measured getBoundingClientRect() of the .doc-controls__controls children:

Collection Marker → icon-buttons icon-buttons width icon-buttons → Save Marker → Save
posts (no icon buttons) 8px 0px 8px 16px
posts-with-preview 8px 24px 8px n/a (preview button in between)

Link to the code that reproduces this issue

https://github.com/VeiaG/payload-4-reproductions/tree/repro-doc-controls-empty-icon-buttons-gap

Source: packages/ui/src/elements/DocumentControls/index.tsx#L306-L317

<div className={`${baseClass}__icon-buttons`}>
  {isLivePreviewEnabled && !isInDrawer && <LivePreviewToggler />}
  {(collectionConfig?.admin.preview || globalConfig?.admin.preview) && (
    <RenderCustomComponent CustomComponent={CustomPreviewButton} Fallback={<PreviewButton />} />
  )}
  {hasScheduledPublishEnabled(collectionConfig || globalConfig) && !isTrashed && (
    <SchedulePublishButton disabled={readOnlyForIncomingUser} />
  )}
</div>

Reproduction Steps

  1. pnpm install && pnpm dev, then open http://localhost:3000/admin.
  2. Open the seeded doc in Posts. Its beforeDocumentControls renders a 32px red square, and the collection has no live preview, admin.preview or scheduled publish.
  3. The square sits 16px from Save. In devtools there is an empty .doc-controls__icon-buttons div between them.
  4. Open the seeded doc in Posts With Preview. It's the same collection plus admin.preview, and the gaps are 8px on each side of the preview button, as intended.

Same result on TanStack Start (pnpm dev:tanstack, checked on beta.6).

Environment Info

payload: 4.0.0-beta.7
@payloadcms/ui: 4.0.0-beta.7
@payloadcms/next: 4.0.0-beta.7 (next 16.4.4)
@payloadcms/tanstack-start: 4.0.0-beta.7
Node: 24
OS: Windows 11

Activity

  1. added
    status: needs-triagePossible bug which hasn't been reproduced yet
    area: uiRelated to the admin panel.
    on Nov 6, 2026
  2. changed the title [-]Document controls: empty `__icon-buttons` wrapper doubles the gap before Save[/-] [+][v4] Document controls: empty `__icon-buttons` wrapper doubles the gap before Save[/+] on Nov 6, 2026
  3. monishpatalay commented on Nov 7, 2026

    @monishpatalay

    Hi! I'd like to pick this up unless you're already on it. Plan: only render doc-controls__icon-buttons when at least one of its children (live preview toggler, preview button, schedule publish) renders, so the gap before Save stays 8px. Would that work?

  4. VeiaG commented on Nov 7, 2026

    @VeiaG
    ContributorAuthor

    @monishpatalay you can do that if you want )

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions