Skip to content

fix: in slugField let position: undefined correctly reset admin.position#15725

Open
zampage wants to merge 1 commit intopayloadcms:mainfrom
zampage:fix/slugfield-position-option
Open

fix: in slugField let position: undefined correctly reset admin.position#15725
zampage wants to merge 1 commit intopayloadcms:mainfrom
zampage:fix/slugfield-position-option

Conversation

@zampage
Copy link
Copy Markdown

@zampage zampage commented Feb 23, 2026

Problem

The slugField provides the option position which accepts 'sidebar' | undefined.
This option is used to populate admin.position.

Per default the slugField adds sidebar when destructuring, making it render in the sidebar.
However providing undefined, with the intent to not render it in the sidebar, does not change this behavior.

slugField({
  position: undefined,
})

The default assignment of position = 'sidebar' while destructuring takes precedence over a provided undefined.

Since the position option exists, it should work with both valid values 'sidebar' and undefined, which currently it does not.

Workaround

A possible workaround before this fix was to use the overrides option of slugField like this:

slugField({
  overrides: (field) => {
    delete field.admin?.position
    return field
  },
}),

Fix

My fix checks the provided options for 'position' in options. Therefore allowing undefined to be passed successfully and not be overriden with sidebar.

const position = 'position' in options ? providedPosition : 'sidebar'

This allows undefined to be passed to admin.position and therefore render the slugfield correctly.

Discord community help source

https://discord.com/channels/967097582721572934/1475457110119546942

@zampage zampage changed the title fix(payload): let position: undefined correctly reset admin.position fix: let position: undefined correctly reset admin.position Feb 23, 2026
@zampage zampage changed the title fix: let position: undefined correctly reset admin.position fix: in slugField let position: undefined correctly reset admin.position Feb 23, 2026
@github-actions github-actions bot added the stale label Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant