Skip to content

Commit e071382

Browse files
authored
fix(ui): upload with has many bulk select not working with postgres (#7976)
Fixes #7921
1 parent bc367ab commit e071382

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/ui/src/fields/Upload/Input.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ export const baseClass = 'upload'
4646
type PopulatedDocs = { relationTo: string; value: JsonObject }[]
4747

4848
export type UploadInputProps = {
49-
readonly Description?: MappedComponent
50-
readonly Error?: MappedComponent
51-
readonly Label?: MappedComponent
5249
/**
5350
* Controls the visibility of the "Create new collection" button
5451
*/
@@ -57,13 +54,16 @@ export type UploadInputProps = {
5754
readonly className?: string
5855
readonly collection?: ClientCollectionConfig
5956
readonly customUploadActions?: React.ReactNode[]
57+
readonly Description?: MappedComponent
6058
readonly description?: StaticDescription
6159
readonly descriptionProps?: FieldDescriptionClientProps<MarkOptional<UploadFieldClient, 'type'>>
60+
readonly Error?: MappedComponent
6261
readonly errorProps?: FieldErrorClientProps<MarkOptional<UploadFieldClient, 'type'>>
6362
readonly field?: MarkOptional<UploadFieldClient, 'type'>
6463
readonly filterOptions?: FilterOptionsResult
6564
readonly hasMany?: boolean
6665
readonly isSortable?: boolean
66+
readonly Label?: MappedComponent
6767
readonly label: StaticLabel
6868
readonly labelProps?: FieldLabelClientProps<MarkOptional<UploadFieldClient, 'type'>>
6969
readonly maxRows?: number
@@ -81,19 +81,19 @@ export type UploadInputProps = {
8181

8282
export function UploadInput(props: UploadInputProps) {
8383
const {
84-
Description,
85-
Error,
86-
Label,
8784
allowNewUpload,
8885
api,
8986
className,
87+
Description,
9088
description,
9189
descriptionProps,
90+
Error,
9291
errorProps,
9392
field,
9493
filterOptions: filterOptionsFromProps,
9594
hasMany,
9695
isSortable,
96+
Label,
9797
label,
9898
labelProps,
9999
maxRows,
@@ -181,7 +181,7 @@ export function UploadInput(props: UploadInputProps) {
181181
async (
182182
ids: (number | string)[],
183183
relatedCollectionSlug: string,
184-
): Promise<PaginatedDocs | null> => {
184+
): Promise<null | PaginatedDocs> => {
185185
const query: {
186186
[key: string]: unknown
187187
where: Where
@@ -213,7 +213,12 @@ export function UploadInput(props: UploadInputProps) {
213213
})
214214
if (response.ok) {
215215
const json = await response.json()
216-
const sortedDocs = ids.map((id) => json.docs.find((doc) => doc.id === id))
216+
const sortedDocs = ids.map((id) =>
217+
json.docs.find((doc) => {
218+
return String(doc.id) === String(id)
219+
}),
220+
)
221+
217222
return { ...json, docs: sortedDocs }
218223
}
219224

0 commit comments

Comments
 (0)