Term selection UI does not handle taxonomy depth

Created on 17 April 2023, about 2 years ago
Updated 18 April 2023, about 2 years ago

Problem/Motivation

If you have a taxonomy with nested terms at different depths, the UI for selecting a term does not reflect the term hierarchy and there's lots of potential for confusion / error.

Steps to reproduce

  1. Create a taxonomy vocabulary with a hierarchy (some terms are children of other terms).
  2. Install bulk_edit_terms.
  3. Visit /admin/content.
  4. Select some nodes.
  5. Use the 'Update terms' action.
  6. Try to find the right term the nested vocabulary.

Proposed resolution

Do the same thing core does in core/modules/taxonomy/src/Form/TermForm.php and indent nested terms with hyphens.

Remaining tasks

User interface changes

The labels in term select drop-downs when bulk editing terms will now use hyphens to represent the term depth in a nested taxonomy vocabulary.

Setup

Given a vocabulary that looks like this at /admin/structure/taxonomy/manage/X/overview:

Before

After

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States dww

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

Comments & Activities

  • Issue created by @dww
  • Status changed to Needs review about 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States dww

    Here's the patch for both 8.x-1.x branch and the 8.x-1.4 official release (which for sites that want to patch that release until 8.x-1.5 is out).

    Note that the existing code is wrongly trying to use t() to get the localized term name. You can only use t() for string literals. This is a "translatable" string that only contains a placeholder, so there's nothing to translate. The localized term name is handled for us when we load the vocabulary tree. See what core is doing in core/modules/taxonomy/src/Form/TermForm.php.

    There are no automated tests for this module, so I'm not including any test coverage. But it's a trivial patch. πŸ˜…

    Please let me know if you have any questions or concerns.

    Thanks!
    -Derek

  • πŸ‡ΊπŸ‡ΈUnited States dww

    Fixing embedded screenshots, sorry for the noise.

  • Status changed to Fixed about 2 years ago
  • πŸ‡ͺπŸ‡ΈSpain fjgarlin

    Thanks so much for creating the issue and the patch. I reviewed it and also tested via drupalpod and I'm happy with the changes.
    I've committed already and I am creating a new tag 8.x-1.5.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024