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

Fix collection sorting for grouped collections #22392

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hanneskuettner
Copy link
Contributor

@hanneskuettner hanneskuettner commented May 6, 2024

Scope

When displaying collections (in selects, lists, system-collection and system-collections) they were only sorted by meta.sort (and the collection name for ties). When grouping selections the sort index starts at 1 again, so the collections appeared out of order with how you would expect it based on the data-model manual sorting.

What's changed:

  • Introduced flattenGroupedCollections (not sure about the name, any suggestions?) to recursively flatten a list of collections that might be (deeply) grouped with the meta.group prop.
  • After talking with @paescuj I moved the sorting to a single source of truth, the collections store
    • Introduced a new sortedCollections getter in addition to the original collections state, that is now used instead of collections whenever a sorted list of collections is needed. As such the collections is not modified and can be used in a backward compatible manner (also it is assigned to outside of the store, introducing the need for either a replaceCollections or the sorted getter)
  • Added more getters in the collection store to ease repetitive filtering, and to use as intermediate lists in the store itself.

Potential Risks / Drawbacks

None

Review Notes / Questions

  • Did I miss any access to .collections that would result in inconsistent sorting behavior?
  • Is the sorting actually less confusing? Sometimes I still struggle with finding the collection easily.

Fixes #21658

Copy link

changeset-bot bot commented May 6, 2024

🦋 Changeset detected

Latest commit: 40d0ac8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@directus/app Patch
@directus/api Patch
directus Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hanneskuettner hanneskuettner changed the title Fix collection for grouped collections Fix collection sorting for grouped collections May 6, 2024
@paescuj paescuj self-assigned this May 6, 2024
@paescuj paescuj marked this pull request as draft May 8, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🆕 Needs Triage
Development

Successfully merging this pull request may close these issues.

Order of related items is random, on 10.9.3
2 participants