Nested taxonomy terms should be ordered by weight

Created on 5 August 2024, 8 months ago
Updated 27 August 2024, 7 months ago

Problem/Motivation

If you have a hierarchical vocabulary, the top-level terms appear in the order that they are weighted in the term list. But child terms appear in order according to their Term IDs. The cause of this is the use of loadTree() versus loadChildren(). loadTree() uses an entity query that orders by weight. loadChildren() doesn't order the results, so it will default to ordering the results by Term ID.

The end result is a confusing experience for content managers. Because they see the top-level terms ordered by the weight that they set. But then the child terms don't do the same thing. They may even think that their new terms are missing from the sitemap if the list is long enough and they didn't scroll down.

Steps to reproduce

  • Make a vocabulary with three terms.
  • Make terms two and three children of the first.
  • Put term three in the order above term two.
  • Configure the sitemap to display the vocabulary.
  • View the sitemap.

Expected result: The sitemap will show terms two and three as children of term one. Term three will be listed before term two.
Actual result: Term two will be listed before term three.

Proposed resolution

Only use loadTree() to load children since it respects the term weights.

Remaining tasks

Review the patch.

User interface changes

Hierarchical vocabulary sitemaps will have their orders changed.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dcam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024