Skip to content

Commit cf8347f

Browse files
authored
fix(ui): disableBulkEdit on ui fields, defaults to true (#8540)
Fixes #8534 UI fields are now excluded by default from the bulk edit view fields options. If you need to have the UI field there, you can provide: ```ts admin: { disableBulkEdit: false } ```
1 parent 157b1e1 commit cf8347f

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

docs/admin/fields.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ export const CollectionConfig: CollectionConfig = {
4040

4141
The following options are available:
4242

43-
| Option | Description |
44-
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45-
| **`condition`** | Programmatically show / hide fields based on other fields. [More details](../admin/fields#conditional-logic). |
46-
| **`components`** | All Field Components can be swapped out for [Custom Components](../admin/components) that you define. [More details](../admin/fields). |
47-
| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](../admin/fields#description). |
43+
| Option | Description |
44+
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45+
| **`condition`** | Programmatically show / hide fields based on other fields. [More details](../admin/fields#conditional-logic). |
46+
| **`components`** | All Field Components can be swapped out for [Custom Components](../admin/components) that you define. [More details](../admin/fields). |
47+
| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](../admin/fields#description). |
4848
| **`position`** | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. |
4949
| **`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. |
50-
| **`style`** | [CSS Properties](https://developer.mozilla.org/en-US/docs/Web/CSS) to inject into the root element of the field. |
51-
| **`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. |
50+
| **`style`** | [CSS Properties](https://developer.mozilla.org/en-US/docs/Web/CSS) to inject into the root element of the field. |
51+
| **`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. |
5252
| **`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. |
53-
| **`disabled`** | If a field is `disabled`, it is completely omitted from the [Admin Panel](../admin/overview). |
54-
| **`disableBulkEdit`** | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. |
53+
| **`disabled`** | If a field is `disabled`, it is completely omitted from the [Admin Panel](../admin/overview). |
54+
| **`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. |
5555
| **`disableListColumn`** | Set `disableListColumn` to `true` to prevent fields from appearing in the list view column selector. |
5656
| **`disableListFilter`** | Set `disableListFilter` to `true` to prevent fields from appearing in the list view filter options. |
57-
| **`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. |
57+
| **`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. |
5858

5959
## Field Components
6060

docs/fields/ui.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ export const MyUIField: Field = {
2828

2929
## Config Options
3030

31-
| Option | Description |
32-
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
33-
| **`name`** \* | A unique identifier for this field. |
34-
| **`label`** | Human-readable label for this UI field. |
31+
| Option | Description |
32+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
33+
| **`name`** \* | A unique identifier for this field. |
34+
| **`label`** | Human-readable label for this UI field. |
3535
| **`admin.components.Field`** \* | React component to be rendered for this field within the Edit View. [More](../admin/components/#field-component) |
3636
| **`admin.components.Cell`** | React component to be rendered as a Cell within collection List views. [More](../admin/components/#field-component) |
37-
| **`admin.disableListColumn`** | Set `disableListColumn` to `true` to prevent the UI field from appearing in the list view column selector. |
38-
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
37+
| **`admin.disableListColumn`** | Set `disableListColumn` to `true` to prevent the UI field from appearing in the list view column selector. |
38+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
3939

4040
_\* An asterisk denotes that a property is required._
4141

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ export const sanitizeFields = async ({
289289
}
290290
}
291291

292+
if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {
293+
field.admin.disableBulkEdit = true
294+
}
295+
292296
if ('_sanitized' in field) {
293297
field._sanitized = true
294298
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@ export type UIField = {
832832
condition?: Condition
833833
/** Extension point to add your custom data. Available in server and client. */
834834
custom?: Record<string, any>
835+
/**
836+
* Set `false` make the UI field appear in the list view column selector. `true` by default for UI fields.
837+
* @default true
838+
*/
835839
disableBulkEdit?: boolean
836840
/**
837841
* Shows / hides fields from appearing in the list view column selector.

packages/ui/src/elements/FieldSelect/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ const reduceFields = ({
9090
}
9191

9292
return fields?.reduce((fieldsToUse, field) => {
93-
// escape for a variety of reasons
93+
// escape for a variety of reasons, include ui fields as they have `name`.
9494
if (
95-
fieldAffectsData(field) &&
95+
(fieldAffectsData(field) || field.type === 'ui') &&
9696
(field.admin.disableBulkEdit ||
9797
field.unique ||
9898
field.admin.hidden ||

0 commit comments

Comments
 (0)