Skip to content

Commit d9b3c07

Browse files
fix: expose type for field's position (#14390)
Adds `FieldPosition = 'main' | 'sidebar'` and uses it in `FieldAdmin` and `AdminClient,` replacing the previous `'sidebar'`-only type. This is especially useful when overriding a plugin field's default `position: 'sidebar'` back to `'main'`, which already worked at runtime but failed type-checking. Also updates the docs to list both options and exports `FieldPosition` from the package index. --------- Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>
1 parent 72396f6 commit d9b3c07

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

docs/fields/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ The following options are available:
620620
| **`condition`** | Programmatically show / hide fields based on other fields. [More details](#conditional-logic). |
621621
| **`components`** | All Field Components can be swapped out for [Custom Components](../custom-components/overview) that you define. |
622622
| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](#description). |
623-
| **`position`** | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. |
623+
| **`position`** | Use `'sidebar'` to render the field in the sidebar or `'main'` (default) to keep it in the main area. |
624624
| **`width`** | Restrict the width of a field. You can pass any string-based value here, be it pixels, percentages, etc. This property is especially useful when fields are nested within a `Row` type where they can be organized horizontally. |
625625
| **`style`** | [CSS Properties](https://developer.mozilla.org/en-US/docs/Web/CSS) to inject into the root element of the field. |
626626
| **`className`** | Attach a [CSS class attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) to the root DOM element of a field. |

packages/payload/src/fields/config/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ export type BlocksFilterOptions<TData = any> =
343343
) => BlockSlugOrString | Promise<BlockSlugOrString | true> | true)
344344
| BlockSlugOrString
345345

346+
export type FieldPosition = 'main' | 'sidebar'
347+
346348
export type FieldAdmin = {
347349
className?: string
348350
components?: {
@@ -385,7 +387,7 @@ export type FieldAdmin = {
385387
*/
386388
disableListFilter?: boolean
387389
hidden?: boolean
388-
position?: 'sidebar'
390+
position?: FieldPosition
389391
readOnly?: boolean
390392
style?: CSSProperties
391393
width?: CSSProperties['width']
@@ -414,7 +416,7 @@ export type AdminClient = {
414416
*/
415417
disableListFilter?: boolean
416418
hidden?: boolean
417-
position?: 'sidebar'
419+
position?: FieldPosition
418420
readOnly?: boolean
419421
style?: { '--field-width'?: CSSProperties['width'] } & CSSProperties
420422
width?: CSSProperties['width']

packages/payload/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,7 @@ export type {
15701570
FieldBaseClient,
15711571
FieldHook,
15721572
FieldHookArgs,
1573+
FieldPosition,
15731574
FieldPresentationalOnly,
15741575
FieldPresentationalOnlyClient,
15751576
FieldTypes,

0 commit comments

Comments
 (0)