payloadcms / payloadcms/payload
[Bug] Top-level group/tabs fields are misaligned on the right (content + separator) vs sibling fields
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug.
Top-level group and tabs fields line up with sibling top-level fields on the left, but are misaligned on the right: their content is inset more (narrower) than sibling fields (e.g. a top-level text field), and their separator (the border) stops short of the right edge. It shows on wide viewports and is most obvious in Live Preview — the narrowed editor column makes the separator stop well before the right edge.
See screenshot: the "Eyebrow" field (inside a top-level group) is visibly narrower than the "Title" field above it.
Important precondition: this only happens when the document has a non-empty sidebar — i.e. at least one field with admin.position: 'sidebar' (which is the common case: slug, status, drafts, etc.). With an empty sidebar, Payload's :has(… .render-fields:empty) rule sets --main-field-margin: initial and everything lines up, so the bug does not reproduce.
Root cause (packages/ui/src/elements/DocumentFields/index.scss): a top-level group/tabs has a symmetric padding-inline: var(--gutter-h). On the left, margin-left: calc(var(--gutter-h) * -1) cancels that padding, so content and border line up. On the right, two values don't track --gutter-h:
--main-gutter-h-rightiscalc(var(--base) * 2)in the base--has-sidebarstate, whereas--main-gutter-h-leftisvar(--gutter-h)— and Payload's own responsive variants already usevar(--gutter-h)on the right. So the right gutter is inconsistent with the left (and with the other breakpoints).--main-field-margin(themargin-rightapplied to> .group-field/> .tabs-field) is a constantcalc(var(--base) * -2)that does not follow--gutter-h, unlikemargin-left. As soon as--gutter-h ≠ 2 × --base(wide viewport, Live Preview…) it no longer cancels the padding → misalignment. (Payload already usescalc(var(--gutter-h) * -1)inside its@include mid-break, which confirms the constant is the anomaly.)
Suggested fix — mirror the right on the left, with values that follow --gutter-h (in .document-fields--has-sidebar):
--main-gutter-h-right: var(--gutter-h); /* like --main-gutter-h-left and the responsive variants */
--main-field-margin: calc(var(--gutter-h) * -1); /* mirror of margin-left, instead of the -2×base constant */
The margin-right of > .group-field / > .tabs-field already reads var(--main-field-margin), so it picks up the corrected value → content and separator align on the right, in the side-by-side layout as well as in Live Preview.
Reproduction Steps
npx create-payload-app(any template).- On a collection, add: a top-level
groupfield (with a few subfields), a top-leveltextfield next to it for comparison, and at least one field withadmin.position: 'sidebar'(so the sidebar is not empty — this is required, see precondition above). Enableadmin.livePreview. - Open a document on a wide viewport: the group's content is narrower on the right than the
textfield, and its separator does not reach the right edge (where the sidebar divider /--main-borderis). - Enable Live Preview: the gap becomes obvious (the separator stops well before the edge). Shrinking the window to a "mobile" width (< 1024px) lines it up again — confirming the behavior depends on the viewport width (while the layout switch depends on the column width).
- Remove the sidebar field (empty sidebar) → the misalignment disappears (
--main-field-margin: initial), confirming the sidebar is the trigger.
Environment Info
Payload: 3.87.1
Node.js: 16.3.0
Next.js: 22.16
Contributor 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.
Research direction
Start in packages/ui/src/elements/DocumentFields/index.scss and reproduce the layout with a non-empty sidebar, a top-level group or tabs field, and Live Preview at a wide viewport. Check the gutter and field-margin variables described in the issue, then verify that content and separators align with sibling fields across side-by-side and Live Preview layouts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100