[v4] Document controls: empty `__icon-buttons` wrapper doubles the gap before Save
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start at packages/ui/src/elements/DocumentControls/index.tsx, especially lines 306–317, where the icon buttons wrapper is rendered. Check the related styles for .doc-controls__controls and the reproduction steps to confirm the extra gap when the wrapper has no children. Done means the gap before Save stays 8px in both cases; no test file is named in the issue.
Written by the indexing model from the issue text.
Description
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):
With admin.preview (8px + 8px) :
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
pnpm install && pnpm dev, then open http://localhost:3000/admin.- Open the seeded doc in Posts. Its
beforeDocumentControlsrenders a 32px red square, and the collection has no live preview,admin.previewor scheduled publish. - The square sits 16px from Save. In devtools there is an empty
.doc-controls__icon-buttonsdiv between them. - 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
- Dominant language
- TypeScript
- Stars
- 45.6k
- Forks
- 4.4k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 237
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from payloadcms/payload
-
plugin-multi-tenant: `isGlobal` collections redirect tenant-scoped users to `/admin` since 3.93.0 (GlobalViewRedirect prop-name mismatch)Possibly taken A pull request linked to this issue is open or already merged. OpenBug plugin: multi-tenant
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
payloadcms/payload#19420 ·
Maintainers usually reply within 1 day
-
area: ui Bug created-by: Contributor status: needs-triage v3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
payloadcms/payload#19413 ·
Maintainers usually reply within 1 day
-
area: ui Bug created-by: Contributor status: needs-triage v3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
payloadcms/payload#19412 ·
Maintainers usually reply within 1 day
-
area: ui Bug created-by: Contributor status: needs-triage v3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
payloadcms/payload#19403 ·
Maintainers usually reply within 1 day
-
area: ui Bug created-by: Contributor status: needs-triage v3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
payloadcms/payload#19396 ·
Maintainers usually reply within 1 day
All issues in payloadcms/payload
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
documentation easy good first issue help wanted
Difficulty 1/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Billion-context documentation addendum: nudge is independent of window occupancy. | billion-context 文档补充:nudge 与窗口占用无关Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
ranxianglei/billion-context#5893 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/monaco-editor#5575 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100