You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ui): relationship filterOptions not applied within the list view (#11008)
Fixes#10440. When `filterOptions` are set on a relationship field,
those same filters are not applied to the `Filter` component within the
list view. This is because `filterOptions` is not being thread into the
`RelationshipFilter` component responsible for populating the available
options.
To do this, we first need to be resolve the filter options on the server
as they accept functions. Once resolved, they can be prop-drilled into
the proper component and appended onto the client-side "where" query.
Reliant on #11080.
|`relationTo`| The collection `slug` to filter against, limited to this field's `relationTo` property |
149
-
|`data`| An object containing the full collection or global document currently being edited |
150
-
|`siblingData`| An object containing document data that is scoped to only fields within the same parent of this field |
151
-
|`id`| The `id` of the current document being edited. `id` is `undefined` during the `create` operation |
152
-
|`user`| An object containing the currently authenticated user |
153
-
|`req`| The Payload Request, which contains references to `payload`, `user`, `locale`, and more. |
139
+
Options can be dynamically limited by supplying a [query constraint](/docs/queries/overview), which will be used both for validating input and filtering available relationships in the UI.
140
+
141
+
The `filterOptions` property can either be a `Where` query, or a function returning `true` to not filter, `false` to prevent all, or a `Where` query. When using a function, it will be called with an argument object with the following properties:
|`blockData`| The data of the nearest parent block. Will be `undefined` if the field is not within a block or when called on a `Filter` component within the list view. |
146
+
|`data`| An object containing the full collection or global document currently being edited. Will be an empty object when called on a `Filter` component within the list view. |
147
+
|`id`| The `id` of the current document being edited. Will be `undefined` during the `create` operation or when called on a `Filter` component within the list view. |
148
+
|`relationTo`| The collection `slug` to filter against, limited to this field's `relationTo` property. |
149
+
|`req`| The Payload Request, which contains references to `payload`, `user`, `locale`, and more. |
150
+
|`siblingData`| An object containing document data that is scoped to only fields within the same parent of this field. Will be an emprt object when called on a `Filter` component within the list view. |
151
+
|`user`| An object containing the currently authenticated user. |
* The data of the nearest parent block. If the field is not within a block, `blockData` will be equal to `undefined`.
272
+
* The data of the nearest parent block. Will be `undefined` if the field is not within a block or when called on a `Filter` component within the list view.
273
273
*/
274
274
blockData: TData
275
275
/**
276
-
* An object containing the full collection or global document currently being edited.
276
+
* An object containing the full collection or global document currently being edited. Will be an empty object when called on a `Filter` component within the list view.
277
277
*/
278
278
data: TData
279
279
/**
280
-
* The `id` of the current document being edited. `id` is undefined during the `create` operation.
280
+
* The `id` of the current document being edited. Will be undefined during the `create` operation or when called on a `Filter` component within the list view.
* An object containing document data that is scoped to only fields within the same parent of this field.
289
+
* An object containing document data that is scoped to only fields within the same parent of this field. Will be an empty object when called on a `Filter` component within the list view.
0 commit comments