This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
m2m list sorting uses PK instead of displaytemplate fields when no sort field is configured #9927
Comments
This isn't a bug: the primary key is used so that when no sort field is defined, the items appear in creation order. |
Well, the following line tells me it was intended to use the (first) displaytemplate field when the sortField wasn't defined.
But this line prevents that:
Looks like a bug to me, but it's now discussion #9929 |
@Oreilles thoughts? |
That seems right... Was using the first field template as a default sort field actually intended ? Using the primary key to use insertion order instead makes more sense to me. Also, if no manual sort is set, shouldn't the sort be done in the api ? That would explain line 22.. |
What benefit does a user have to see m2m items sorted on a identity value instead of alphabetically on the name of this item?
Yes absolutely, that's also how I initially thought it would work. |
None at all, but it does make sense as the default for "sort field = null". That being said, I think it'd be a great optimization if we could default the sortField option to be the first field in the display template, so it's explicit, but still have the logic default to whatever the default is in the API when the sortField option is set to |
By this you mean if SortField is empty and a display template is set, SortField gets automatically filled with the first field used in the display template? I was under the impression SortField was used to store the sort order after manually resorting the items via drag-n-drop. Feels tricky to me to use the same field to select a sorting field in a (related) table from which you don't want the value to be overwritten after drag-n-drop.
This default would then be the sort field as configured in a preset of the junction table used in the m2m relation? |
Ah yeah my bad. I was confusing this with an option to set the display sort-value for when you don't have a manual drag-and-drop sort field configured under the relationship settings, which is currently not a thing yet but something I'd envision could be part of the sprint to add #9135 |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Preflight Checklist
Describe the Bug
When no sort field is configured for a relation, the PK is used as the default sort field instead of using the field(s) used in the display template. This results in a seemingly random list of items in the m2m interface.
I have a PR ready.
To Reproduce
{{book_id.title}} - {{book_id.subtitle}}
to the interfacesort
to the relationErrors Shown
No response
What version of Directus are you using?
9.0.1
What version of Node.js are you using?
v16.13.0
What database are you using?
MSSQL
What browser are you using?
Chrome
What operating system are you using?
Windows
How are you deploying Directus?
running locally
The text was updated successfully, but these errors were encountered: