Skip to content

Tag lists are shown in the server's order instead of being sorted for display #4248

Closed

Description

@pbleser-oc

The tag lists in the web UI are shown in whatever order the server returns them. Today that order is effectively random: it depends on the search engine in use (bleve or OpenSearch) and on the order of its results, so it can change between two page loads. The web client should sort the tags itself, for display, in the user's language.

Where: all three tag lists take the result of listTags() without sorting:

  • tag filter in the search results: packages/web-app-files/src/components/Search/List.vue (loadAvailableTagsTask, ~line 294)
  • tag filter in the favorites view: packages/web-app-files/src/views/Favorites.vue (loadAvailableTagsTask, ~line 202)
  • tag picker in the sidebar: packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue (loadAvailableTagsTask, ~line 140)

listTags() in packages/web-client/src/graph/tags/tags.ts passes the value of GET /graph/v1.0/extensions/org.libregraph/tags through unchanged. (Line numbers as of main at 9709827.)

Server side: opencloud-eu/opencloud#3891 makes the server order deterministic: it returns the distinct tags sorted in byte order, cut at 100 (fixing opencloud-eu/opencloud#3889). Byte order is chosen on purpose, so that the search engines can later return pre-sorted, limited tag lists that can be merged exactly (opencloud-eu/opencloud#3890). It is not meant for display: upper case comes before lower case ("Zebra" before "apple"), and digits and symbols come first. So once #3891 is merged, the lists become stable but show that unusual order until the web client sorts them.

Expected: each tag list is sorted for display with a locale-aware, case-insensitive comparison in the user's current language, e.g. Intl.Collator(language, { sensitivity: 'base' }).compare or a.localeCompare(b, language, { sensitivity: 'base' }). Tags that compare equal (e.g. "Work" and "work") should still get a fixed order (e.g. fall back to a plain comparison), so the list doesn't jump.

Notes for the fix:

  • Sorting once where the list is loaded is enough; the server only returns at most 100 tags.
  • Whether to sort centrally (listTags() or a shared helper) or in each of the three components is up to you. The components know the current UI language; web-client doesn't, as far as I can see.
  • The tags the user types or has assigned to a file (selectedTags/currentTags in TagsSelect.vue) are a separate list; only the list of available tags is affected here.
  • A unit test with mixed case, umlauts/accents and digits (e.g. ["Zebra", "apple", "Äpfel", "10", "banana"]) would cover it.

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions