payload icon indicating copy to clipboard operation
payload copied to clipboard

Wrong placeholder on related search

Open mat-twg opened this issue 1 year ago • 7 comments

Link to reproduction

No response

Describe the Bug

Wrong placeholder on related search

image

image

Expected placeholder:

Serach by Name, Type Or File Name

To Reproduce

Create two collections and run:

export const DocumentsTypes: CollectionConfig = {
  slug: 'documents-types',
  admin: {
    useAsTitle: 'name',
  },
  access: {
    read: () => true,
  },
  fields: [
    {
      name: 'name',
      type: 'text',
      required: true,
    },
  ],
}

export const Documents: CollectionConfig = {
  slug: 'documents',
  admin: {
    useAsTitle: 'name',
    listSearchableFields: ['filename', 'name', 'type.name'],
  },
  upload: {
    staticDir: path.resolve(__dirname, '../../../../documents'),
    mimeTypes: ['application/pdf'],
  },
  access: {
    read: () => true,
  },
  fields: [
    {
      name: 'type',
      type: 'relationship',
      relationTo: 'documents-types',
      required: true,
    },
    {
      name: 'name',
      type: 'text',
      required: true,
    },
  ],
}

Payload Version

2.8.2

Adapters and Plugins

No response

mat-twg avatar Jan 24 '24 19:01 mat-twg

I think Payload is not provide searching field value in related document.

However, you cannot query on any field values within the related document. Since we are referencing multiple collections, the field you are querying on may not exist and break the query.

https://payloadcms.com/docs/fields/relationship#querying-and-filtering-polymorphic-relationships

that placeholder is correct because related field value is not provided, so skip presenting.

SimYunSup avatar Jan 25 '24 01:01 SimYunSup

I think Payload is not provide searching field value in related document.

However, you cannot query on any field values within the related document. Since we are referencing multiple collections, the field you are querying on may not exist and break the query. https://payloadcms.com/docs/fields/relationship#querying-and-filtering-polymorphic-relationships

that placeholder is correct because related field value is not provided, so skip presenting.

provided as well by mongodb

image image

mat-twg avatar Jan 25 '24 07:01 mat-twg

Sorry, I got it wrong. It is working beacause querying on non-polymorphic relationship is working.

But It must be work like new feature.

In the case of polymorphic and nested field in relocation field, there may be a lot of errors, and I think there should be a discussion on how to handle the label.

SimYunSup avatar Jan 25 '24 09:01 SimYunSup

What is there to think? the table(document/collecction) has a type (eg. type.name, type.anything.field) field, it is indicated in the listSearchableFields, it should be displayed in the placeholder, the errors you mention should be taken care of by the developer.

-- Just take first split by '.' not the last one, or print TypeName

mat-twg avatar Jan 25 '24 10:01 mat-twg

  1. It can produce a lot of bug because there is many edge cases. This is just working because relationship field in where is working. So I think it is not just developing problem.
    • nested value in relationship field.
    • Access denied field in relationship field.
    • relationship field in relationship field.
    • How about i18n?
  2. I think it is better to use filter option. I think searching on field in relationship field must be disabled on listSearchableFields. And if you want to relationship field in listSearchableFields, It will be New Feature.

SimYunSup avatar Jan 26 '24 02:01 SimYunSup

Everything you described is of course the case... but still it seems to me that this applies to relational databases as well, however we are discussing a simple thing - this is the value in the placeholder, no matter what the base is, it will be the same in all cases , for example: field.name -> FieldName As for "i18n", it still does not work correctly or requires additional configuration of the search fields.

mat-twg avatar Jan 28 '24 11:01 mat-twg

I think this request should be categorized as New Feature as we need "additional configuration". The reason I listed the cases is that I need additional configuration for such edge cases.

If this is a bug, I think it is a bug that does not cause errors when the field (ex. type.name ) is put in listSearchableFields.

SimYunSup avatar Feb 02 '24 02:02 SimYunSup

This issue was automatically closed due to lack of activity. If this issue is still relevant against the latest codebase, please create a new issue.

github-actions[bot] avatar Dec 06 '24 15:12 github-actions[bot]

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Dec 08 '24 04:12 github-actions[bot]