Conditionally show Operations, Weight column in Vocabulary, Terms overview

Created on 7 November 2017, almost 8 years ago
Updated 12 August 2025, 13 days ago

Problem/Motivation

The vocabulary overview page and the term overview page always show the Weight and Operations column. Preferably these columns are only visible when applicable. Also, the display and markup are broken when the current user can has permissions to view the taxonomy overview page, but not to edit terms.

Proposed resolution

  1. Display the 'Weight' column including tabledrag when the current user can update all listed entities and the list contains more than a single item.
  2. Display the 'Operations' column when at least one entity has an operation for the current user.

The patch file must include add test coverage to test the above changes. For reference view the test implementation of /core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

The 'Weight' and 'Operations' columns display only when applicable on the Vocabulary overview page and Term overview page.

API changes

None.

Data model changes

None.

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

taxonomy.module

Created by

πŸ‡³πŸ‡±Netherlands idebr

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

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

    I have a use case for showing the taxonomy overview page to users who can't create or edit terms.

    On a site with a controlled vocabulary, it will likely require more privileges to update the vocabulary than to tag content with that vocabulary. For example, Content Editors would be able to tag their content with existing terms, but only administrators would be able to add, edit, or rearrange terms.

    As a Content Editor on this site, how would you understand the structure of the vocabulary so you can use it correctly? The two interfaces for tagging (autocomplete and select list / checkbox) don't do a good job of showing you a big, strucured vocabulary. It would be useful to be able to see the overview page.

    Also, this permissions setup still produces invalid table markup.

    To reproduce this issue:

    1. Install the latest Drupal 11.x branch with the standard profile, which will use the Claro admin theme.
    2. Log in as an administrator.
    3. Change the Content Editor role permissions:
      • Remove Create terms and Edit terms in the Tags vocab.
      • Add Access taxonomy overview.
    4. Save permissions.
    5. Create 5 to 10 terms in the Tags vocab and arrange them with three or more levels of depth.
    6. View the Tags overview page.

    7. Note the appearance of the drag handles, the Status column, and the Operations column.
    8. Note that depth is shown by indenting. (BTW this is an accessibility issue.)
    9. Press the Show row weights button.

    10. Note the Weight column is shown and the drag handles are hidden. Terms are still indented to show depth.
    11. Create a user with the Content Editor role.
    12. Log in as the Content Editor.
    13. View the Tags overview page.

    14. Note there is no "Show row weights" button, and both the Operations and Weight columns are empty.
    15. Note the following display issues:
      • Drag handle images are displayed, but they are unstyled and don't do anything.
      • Items deeper than second level show multiple drag handles.
      • Row hover highlight doesn't extend to Weight column.
      • There is no indenting for depth.
    16. Note the following invalid markup:
      • The header row has 4 cells, but each data row only has 3 cells.

    This seems more like a bug than a feature request. The system shouldn't produce invalid markup just because of some less-common combination of permissions.

    One thing that's happening is that the tabledrag CSS and JS is not being added to the overview page when there is no edit terms permission. That makes sense from a permissions perspective, but because those assets are what control display of the drag handles and the weight column, we end up with this broken display.

    The initial approach might be to fix what's broken, and then discuss whether to try hiding the Operations column if it's empty. Is there something we can borrow from the Views hide empty column feature?

    If this approach sounds good then I will update the issue summary.

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

    After doing some more searching of the issue queue, it looks like πŸ› Taxonomy Term List page is broken when users don't have permission to edit/create terms Active is a better place to discuss the issues with the permission combination.

Production build 0.71.5 2024