diff --git a/docs/admin/fields.mdx b/docs/admin/fields.mdx index f34019928..11bef66b5 100644 --- a/docs/admin/fields.mdx +++ b/docs/admin/fields.mdx @@ -40,21 +40,21 @@ export const CollectionConfig: CollectionConfig = { The following options are available: -| Option | Description | -| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`condition`** | Programmatically show / hide fields based on other fields. [More details](../admin/fields#conditional-logic). | -| **`components`** | All Field Components can be swapped out for [Custom Components](../admin/components) that you define. [More details](../admin/fields). | -| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](../admin/fields#description). | +| Option | Description | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **`condition`** | Programmatically show / hide fields based on other fields. [More details](../admin/fields#conditional-logic). | +| **`components`** | All Field Components can be swapped out for [Custom Components](../admin/components) that you define. [More details](../admin/fields). | +| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](../admin/fields#description). | | **`position`** | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. | | **`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. | -| **`style`** | [CSS Properties](https://developer.mozilla.org/en-US/docs/Web/CSS) to inject into the root element of the field. | -| **`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. | +| **`style`** | [CSS Properties](https://developer.mozilla.org/en-US/docs/Web/CSS) to inject into the root element of the field. | +| **`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. | | **`readOnly`** | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. | -| **`disabled`** | If a field is `disabled`, it is completely omitted from the [Admin Panel](../admin/overview). | -| **`disableBulkEdit`** | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. | +| **`disabled`** | If a field is `disabled`, it is completely omitted from the [Admin Panel](../admin/overview). | +| **`disableBulkEdit`** | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. Defaults to `true` for UI fields. | | **`disableListColumn`** | Set `disableListColumn` to `true` to prevent fields from appearing in the list view column selector. | | **`disableListFilter`** | Set `disableListFilter` to `true` to prevent fields from appearing in the list view filter options. | -| **`hidden`** | Will transform the field into a `hidden` input type. Its value will still submit with requests in the Admin Panel, but the field itself will not be visible to editors. | +| **`hidden`** | Will transform the field into a `hidden` input type. Its value will still submit with requests in the Admin Panel, but the field itself will not be visible to editors. | ## Field Components diff --git a/docs/fields/ui.mdx b/docs/fields/ui.mdx index bf09e543a..776866297 100644 --- a/docs/fields/ui.mdx +++ b/docs/fields/ui.mdx @@ -28,14 +28,14 @@ export const MyUIField: Field = { ## Config Options -| Option | Description | -| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | A unique identifier for this field. | -| **`label`** | Human-readable label for this UI field. | +| Option | Description | +| ------------------------------- | ------------------------------------------------------------------------------------------------------------------- | +| **`name`** \* | A unique identifier for this field. | +| **`label`** | Human-readable label for this UI field. | | **`admin.components.Field`** \* | React component to be rendered for this field within the Edit View. [More](../admin/components/#field-component) | | **`admin.components.Cell`** | React component to be rendered as a Cell within collection List views. [More](../admin/components/#field-component) | -| **`admin.disableListColumn`** | Set `disableListColumn` to `true` to prevent the UI field from appearing in the list view column selector. | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`admin.disableListColumn`** | Set `disableListColumn` to `true` to prevent the UI field from appearing in the list view column selector. | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | _\* An asterisk denotes that a property is required._ diff --git a/packages/payload/src/fields/config/sanitize.ts b/packages/payload/src/fields/config/sanitize.ts index 1622ad8ba..9ff611488 100644 --- a/packages/payload/src/fields/config/sanitize.ts +++ b/packages/payload/src/fields/config/sanitize.ts @@ -289,6 +289,10 @@ export const sanitizeFields = async ({ } } + if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') { + field.admin.disableBulkEdit = true + } + if ('_sanitized' in field) { field._sanitized = true } diff --git a/packages/payload/src/fields/config/types.ts b/packages/payload/src/fields/config/types.ts index 997a83c34..3a964a8ed 100644 --- a/packages/payload/src/fields/config/types.ts +++ b/packages/payload/src/fields/config/types.ts @@ -832,6 +832,10 @@ export type UIField = { condition?: Condition /** Extension point to add your custom data. Available in server and client. */ custom?: Record + /** + * Set `false` make the UI field appear in the list view column selector. `true` by default for UI fields. + * @default true + */ disableBulkEdit?: boolean /** * Shows / hides fields from appearing in the list view column selector. diff --git a/packages/ui/src/elements/FieldSelect/index.tsx b/packages/ui/src/elements/FieldSelect/index.tsx index 83a617084..d38288037 100644 --- a/packages/ui/src/elements/FieldSelect/index.tsx +++ b/packages/ui/src/elements/FieldSelect/index.tsx @@ -90,9 +90,9 @@ const reduceFields = ({ } return fields?.reduce((fieldsToUse, field) => { - // escape for a variety of reasons + // escape for a variety of reasons, include ui fields as they have `name`. if ( - fieldAffectsData(field) && + (fieldAffectsData(field) || field.type === 'ui') && (field.admin.disableBulkEdit || field.unique || field.admin.hidden ||