Skip to content

fix: sort root nodes unless opted out via suppressAlphabeticalSorting#1753

Open
HendrikThePendric wants to merge 3 commits into
masterfrom
fix/sort-org-unit-root-nodes-by-display-name
Open

fix: sort root nodes unless opted out via suppressAlphabeticalSorting#1753
HendrikThePendric wants to merge 3 commits into
masterfrom
fix/sort-org-unit-root-nodes-by-display-name

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Implements LIBS-864


Description

Root nodes are now sorted alphabetically unless opted out via suppressAlphabeticalSorting. I've scoped this as a fix, because I'd say that this behaviour should have been implemented all along. Sorting children but not roots, while having a generic suppressAlphabeticalSorting prop in place is inconsistent behaviour.

Incidental

  • I deduped the deps as well
  • It seems an i18n string for the select was missing, it "popped up" when ran yarn setup. Not sure why it didn't get added before, but it seems like a valid addition to me.

Checklist

  • API docs are generated N/A
  • Tests were added
  • Storybook demos were added N/A

@HendrikThePendric HendrikThePendric requested a review from a team as a code owner June 29, 2026 08:03
@sonarqubecloud

Copy link
Copy Markdown

@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-1753--dhis2-ui.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify June 29, 2026 08:07 Inactive
@tomzemp tomzemp self-requested a review July 6, 2026 08:26

@tomzemp tomzemp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @HendrikThePendric 🙏 . I've read through the code and tested in the users app (data entry app has custom org unit tree, so we'll need to copy these changes).

The only thing I noticed on review is that the existing helper function sortNodeChildrenAlphabetically is using left.displayName.localeCompare(right.displayName). I guess this then uses the sorting conventions of the browser language, whereas we might want to use the user's ui language? This can cause some differences in the sort, e.g. English would alphabetise [Åland, Belgium, Zimbabwe] whereas Norwegian would alphabetise [Belgium, Zimbabwe, Åland] (or English [na,ño,ny], vs Spanish [na,ny,ño]). I think this is a minor issue, but might be nice to fix in the context of this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants