Languages: Sort the global content language selector (closes #22628) - #22711
Conversation
|
Claude finished @AndyButland's task in 3m 29s —— View job PR ReviewTarget: Adds a
Suggestions
Approved with Suggestions for improvementClean, well-scoped, and correctly tested. The implementation mirrors the pattern from the variant selector and includes a spread-copy before sort ( |
There was a problem hiding this comment.
Pull request overview
Improves the usability of the global Content-tree language dropdown by sorting available languages in a consistent, scan-friendly order (matching the earlier variant-selector behavior): default language first, then mandatory languages, then alphabetical by language name.
Changes:
- Added a
sortLanguagescomparator utility under@umbraco-cms/backoffice/language. - Applied the new sorting in
umb-app-language-select(without changing repository/context ordering for other consumers). - Added unit tests covering priority chain behavior and missing-name handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Umbraco.Web.UI.Client/src/packages/language/utils.ts |
Introduces the sortLanguages comparator (default → mandatory → name). |
src/Umbraco.Web.UI.Client/src/packages/language/utils.test.ts |
Adds unit tests validating the sorting rules and edge cases. |
src/Umbraco.Web.UI.Client/src/packages/language/index.ts |
Re-exports the new utility from the package index. |
src/Umbraco.Web.UI.Client/src/packages/language/app-language-select/app-language-select.element.ts |
Applies sorting at the language selector consumer by sorting fetched items. |
1e2ff2d to
b4a49b8
Compare
engijlr
left a comment
There was a problem hiding this comment.
Clean fix! Tested and work as expected 👍
|
A few notes for future ideas: As a principle, I think it is wrong to order a paginated endpoint on the consumer side. I know that the languages entity is an area where we are least likely to encounter problems because there is a limit to how many languages you can actually create. At a minimum, we need to ensure that all languages are loaded on the client by comparing the received amount with the total and continuing to request until we have them all. I think this is a good opportunity to figure out how “advanced” ordering could be implemented in the Management API to provide more flexibility for consumers. Would it be possible to develop an API design that produces the same order we currently have on the client by combining different ordering parameters? |
|
This pull request has been mentioned on Umbraco community forum. There might be relevant details there: https://forum.umbraco.com/t/umbraco-languages-sortorder/7939/4 |
|
Thanks for the feeback @madsrasmussen. I've raised #22765 to address:
With regard to the ordering, I did think about whether this should be server-side but in the end applied it client-side to align with what we were already doing for the variant selector. But I don't see any harm in pushing it up to the management API endpoint. Perhaps an |
Description
Fixes #22628 which reports that the language dropdown above the content tree lists languages in insert order, which is hard to scan when there are many.
This PR aligns its ordering with the document workspace variant selector (fixed earlier in PR #21435): default first, then mandatory, then alphabetical by name.
Testing
E.g. here I have created English (default), Italian and French. Previously they would display in that order. Now they are:
If I make Italian mandatory, it is shown above French.