Problem/Motivation

When user has access to view the list of terms/taxonomy overview page and they don't have access to manage them, the style is broken and confusing.

The user sees a + SVG but no indentation. It's quite hard to distinguish between parent and child terms.

Also, the Weight column appears and is empty. The column is included in the data rows but not the header, resulting in invalid markup.

Screenshot showing the style issue when user doesn't have access to update the terms.

The problem is that the tabledrag SVGs (indentation and handles) and the weight are added in code, but their styling and functionality depend on the tabledrag JS and CSS. These assets are not added to the term overview page when the current user doesn't have edit terms permissions, resulting in a broken display and invalid markup.

Steps to reproduce

  1. Create a taxonomy
  2. Add few terms
  3. Add children terms so you can get the indentation
  4. Create new role with vocabulary overview access only
  5. Login and visit taxonomy terms

Proposed resolution

Add consistent permission checks so that all tabledrag-related code and assets are handled the same way.

Remaining tasks

Tests

User interface changes

Users with vocabulary overview access but without term edit access will not see the drag handle images or the Weight column.

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

TBD

Issue fork drupal-3499441

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

carolpettirossi created an issue. See original summary.

quietone’s picture

Version: 10.4.x-dev » 11.x-dev
Issue summary: View changes

Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies.

saurav-drupal-dev’s picture

Issue tags: +Needs steps to reproduce
StatusFileSize
new245.69 KB

did u logged in using admin account or its just a normal account without admin access because i am not able to reproduce the issue here.

no issue found

please share a short video of the issue. thanks

carolpettirossi’s picture

@saurav-drupal-dev, you must remove the permission to create/edit terms and add the view overview,

See the permissions here for content editor:

Screenshot of the permissions UI

Evidence that the layout is broken for the user with content editor role:

Taxonomy list is broken when user doesn't have access to manage terms

kushagra.goyal’s picture

StatusFileSize
new99.16 KB
new87 KB

Issue is able replicate on local, Here this issue coming due to styled components as they would be only view only access to editors. Hence does not containing draggable table that doesn't allow svg and indentation styles get rendered, so for Proposed solution is to create a separate component style to overwrite as below.

/* *
 * @file
 * Styles for custom indentation and tree item visibility for view access.
 */
.indentation {
    position: relative;
    inset-inline-start: calc(var(--space-xs)* -0.5);
    float: left; /* LTR */
    width: 1.5625rem;
    height: 1.5625rem;
    background: none !important;
    line-height: 0;
}

[dir="rtl"] .indentation {
    float: right;
}

.tree__item {
    display: none;
}

Did a try on my system it worked for me. (as image attached). not sure so, I would like to explore any other potential solutions to address this. if all good Will Raise MR.

kushagra.goyal’s picture

Issue summary: View changes
Issue tags: -Needs steps to reproduce
brunoalmeida’s picture

StatusFileSize
new17.91 KB

@kushagra.goyal What if all the code related to .indention and .tree classes was moved to the new indentation.pcss.css file?
It looks like this block of code can be completely extracted from the tabledrag.css file.

/* *
 * @file
 * Styles for custom indentation and tree item visibility for view access.
 */

/**
 * Indentation.
 */
.indentation {
  position: relative;
  inset-inline-start: calc(var(--space-xs) * -0.5);
  float: left; /* LTR */
  width: 25px;
  height: 25px;
  background: none !important;
  line-height: 0;

  @nest .tabledrag-cell-content & {
    /* Fixes Safari bug (16.1 at least) where table rows are overly large when
      using indentation (e.g. re-ordering menu items. */
    display: inline-flex;
    float: none;
    overflow: hidden;
    flex-direction: column;
    height: 100%;
  }

  @nest [dir="rtl"] & {
    float: right;
  }
}

/**
 * Tree is the visual representation for the simultaneously moved draggable
 * rows.
 *
 * These rules are styling the inline SVG that is placed inside the .indentation
 * element.
 */
.tree {
  width: 25px;
  height: 25px;
}

.tree__item {
  display: none;
}

/* LTR tree child. */
.tree-child path {
  &:not(.tree__item-child-ltr) {
    display: none;
  }

  &.tree__item-child-ltr {
    display: block;
  }
}

/* RTL tree child. */
[dir="rtl"] {
  & .tree-child path {
    &:not(.tree__item-child-rtl) {
      display: none;
    }
    &.tree__item-child-rtl {
      display: block;
    }
  }

  /* Last RTL tree child. */
  & .tree-child-last path {
    &:not(.tree__item-child-last-rtl) {
      display: none;
    }
    &.tree__item-child-last-rtl {
      display: block;
    }
  }
}

/* Last LTR tree child. */
.tree-child-last path {
  &:not(.tree__item-child-last-ltr) {
    display: none;
  }
  &.tree__item-child-last-ltr {
    display: block;
  }
}

/* Horizontal line. */
.tree-child-horizontal path {
  &:not(.tree__item-horizontal) {
    display: none;
  }

  &.tree__item-horizontal {
    display: block;
  }
}

I have tested your suggestion and I can confirm it's working fine.

Evidence New Css

kushagra.goyal’s picture

Hi @brunoalmeida, thanks for looking into this. Yeah It will ok by adding code for tree and indentation As Tree is the visual representation for draggable rows. This will help item visibility for view access.

brunoalmeida’s picture

Status: Active » Needs work
StatusFileSize
new8.44 KB

I needed to fix this in my current project so I have created a MR using the @kushagra.goyal solution.
I'm also adding a patch for Core version 10.4.x.

brunoalmeida’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs subsystem maintainer review

Tried replicating this following the steps but not getting the results mentioned. Think more information is needed. Adding a new file and editing a library probably will need sub-maintainer approval too.

lisotton made their first commit to this issue’s fork.

lisotton’s picture

Status: Needs work » Needs review

I resolved the conflict and changed the class "tabledrag-cell-content" in the "indentation.css" to "tabledrag-cell", as the "tabledrag-cell-content" is created by JS when tabledrag is enabled.

I had the same problem in the menu form when the tabledrag is disabled using a form alter.

@smustgrave you can replicate the issue creating a menu with some items in different levels and then with a form alter doing:
unset($form['links']['links']['#tabledrag']);

cboyden’s picture

Status: Needs review » Needs work

I was looking at #2921700: Conditionally show Operations, Weight column in Vocabulary, Terms overview and posted a comment there, but it looks like this is a better issue for it. The problem isn't only the display, it's also the invalid markup.

I believe the source of the problem is that the tabledrag SVGs (indentation and handles) and the Weight header are added in code, but their styling and functionality depend on the tabledrag JS and CSS. These assets are not added to the term overview page when the current user doesn't have edit terms permissions, resulting in a broken display and invalid markup.

Steps to reproduce:

  1. Install the latest Drupal 11.x branch with the standard profile.
  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.

I tested the latest MR and it still produces invalid markup: The header row has 4 cells, but each data row only has 3 cells.

brunoalmeida’s picture

@cboyden currently, the "Weight" thead is always created. There's only a condition for the label, as you can see below:

'weight' => !$operations_access ? $this->t('Weight') : NULL,

The weight column that is created for each term has a different validation:

if ($update_tree_access->isAllowed()) {
  $form['terms'][$key]['weight'] = [
    '#type' => 'weight',
    '#delta' => $delta,
    '#title' => $this->t('Weight for added term'),
    '#title_display' => 'invisible',
    '#default_value' => $term->getWeight(),
    '#attributes' => ['class' => ['term-weight']],
  ];
}

My proposal is to create the Weight thead separately, combining the two validations:

$weight_reset_allowed = !$operations_access && $update_tree_access->isAllowed();

if ($weight_reset_allowed) {
  $form['terms']['#header']['weight'] = $this->t('Weight');
}

This validation can be used to add any element that has to do with weights and drag and drop.
I updated the MR with these changes.

cboyden’s picture

Status: Needs work » Needs review

Thanks @brunoalmeida, I tried this out locally and it's working as expected.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Seems like an issue that probably should have test coverage, since the fix was in the taxonomy module wonder if the component should be set to that.

Also current solution doesn't match the summary where this was originally about adjusting styling

cboyden’s picture

Issue summary: View changes

I've updated the issue summary with more info about the invalid markup and a new proposed resolution.

It is possible that this problem occurs in other places that use tabledrag, but that would require more investigation.

brunoalmeida’s picture

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Needs work

This was marked as needing tests in #18. None have been added, so I'm restoring the Needs Work status.

ironnuts’s picture

It seems the latest code has broken VocabularyPermissionsTest.php. That file looks like where test coverage can be placed, too. For example line 107 is a comment:

// Login as a user without any of the required permissions.

And line 115 contains this comment:

// Log in as a user with only the overview permission,..

ironnuts’s picture

I think that fixes the VocabularyPermissionsTest.php. There are now 2x seeming unrelated Unit test failing. I am not sure what new test coverage is needed.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Needs work » Postponed

The Claro theme was approved for removal in #3576460: [policy, no patch] Deprecate and remove Claro.

This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3576668: [meta] Tasks to deprecate Claro and the removal work in #3584638: [meta] Tasks to remove the Claro theme.

smustgrave’s picture

Project: Drupal core » Claro
Version: main » 3.0.x-dev
Component: Claro theme » Code
Status: Postponed » Needs work

Claro has moved to contrib

inaw’s picture

StatusFileSize
new13.05 KB

Reupload patch for MR 11112 11.4.x