Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relation autocomplete: searching by ID doesn't work properly #5573

Closed
nickjanssen opened this issue Mar 23, 2020 · 3 comments
Closed

Relation autocomplete: searching by ID doesn't work properly #5573

nickjanssen opened this issue Mar 23, 2020 · 3 comments
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:admin Source is core/admin package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@nickjanssen
Copy link

As requested by @lauriejim this is a new bug report related to #4025

Describe the bug
When using relations, which by default shows up as IDs, searching and selecting IDs doesn't work. Random/wrong IDs are shown.

Steps to reproduce the behavior

  1. Create a relation between two collections
  2. Try searching for specific IDs in the autocomplete field

Expected behavior
IDs should show up when searching for them in the autocomplete.

Screenshots

An entry starting with 5d1 is clearly present in the list, yet it doesn't show up when searching for it.

System

  • Node.js version: 12
  • NPM version: ?
  • Strapi version: beta 19
  • Database: MongoDB
  • Operating system: Ubuntu
@petersg83
Copy link
Contributor

petersg83 commented Mar 23, 2020

Thanks, I can reproduce the issue.

There are several issues/questions regarding this problem.

The input displays only one attribute (in your example it's the ID).
The query sent from the front is: url?_q=5d1 and it doesn't specify on which attribute the search is made.
The backend receives the query and will search for the entries in the database by searching on all the attributes of the model (except for id, lastUpdatedAt and createdAt).
The backend finds some results and answers the front query with them (limit of 20 results).
The front receives the response and filters on the attributes it displays (still ID in your case).

Capture d’écran 2020-03-23 à 16 42 03
In the sceenshot above the input display the firstname attribute. The back returns Ada LOVELACE but the front displays no results

All this workflow brings different issues:

  1. The front displays the attributes ID but the back doesn't search within this attribute (your case)
  2. The front may display no result even though they exists (see example below)

Example Issue n°2:
Let's say you have students in your database with a firstname and a lastname.

01. firstname: ADA  ; lastname: LOVELACE
02. firstname: ADA  ; lastname: LOVELACE
03. firstname: ADA  ; lastname: LOVELACE
04. firstname: ADA  ; lastname: LOVELACE
05. firstname: ADA  ; lastname: LOVELACE
06. firstname: ADA  ; lastname: LOVELACE
07. firstname: ADA  ; lastname: LOVELACE
08. firstname: ADA  ; lastname: LOVELACE
09. firstname: ADA  ; lastname: LOVELACE
10. firstname: ADA  ; lastname: LOVELACE
11. firstname: ADA  ; lastname: LOVELACE
12. firstname: ADA  ; lastname: LOVELACE
13. firstname: ADA  ; lastname: LOVELACE
14. firstname: ADA  ; lastname: LOVELACE
15. firstname: ADA  ; lastname: LOVELACE
16. firstname: ADA  ; lastname: LOVELACE
17. firstname: ADA  ; lastname: LOVELACE
18. firstname: ADA  ; lastname: LOVELACE
19. firstname: ADA  ; lastname: LOVELACE
20. firstname: ADA  ; lastname: LOVELACE
21. firstname: LOVERE  ; lastname: VAGRANT

If the front input displays the firstname and you type LOVE, then, it is possible that the front will display that there are no results. (Backend will send the first 20 entries and frontend will filter on firstname and see no LOVE in all those ADA firstnames).

Then if you type LOVER, the front will receive the entry 21 and will display it.
It's a strange, not wanted, behavior.

The solution I propose for both issues is :
The front uses param ?ID_contains=5d1 instead of ?_q=5d1

NB: It would have been an interesting feature to search for all attributes but it seems that it is not what we want for the moment.

@petersg83 petersg83 assigned petersg83 and unassigned petersg83 Mar 23, 2020
@petersg83 petersg83 added good first issue Good for newcomers severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:admin Source is core/admin package issue: bug Issue reporting a bug labels Mar 23, 2020
@alexandrebodin alexandrebodin added the status: confirmed Confirmed by a Strapi Team member or multiple community members label Mar 24, 2020
@dkarski dkarski mentioned this issue Mar 27, 2020
@minhnghiadev
Copy link

I have this issue, too. Any update for this in furture? Now, I can't find my record because the result has been limited with 20 records.

@dkarski
Copy link
Contributor

dkarski commented Mar 30, 2020

@minhnghiadev issue has resolved in this PR #5623. Please check-in the in 3.0.0-beta.19.4 version 💪

@strapi strapi locked as resolved and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve source: core:admin Source is core/admin package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
None yet
Development

No branches or pull requests

5 participants