DraggableListBuilder / DraggableListBuilderTrait is brittle with its table cells

Created on 6 March 2024, 10 months ago

Problem/Motivation

If an entity list builder using DraggableListBuilder / DraggableListBuilderTrait doesn't add anything to its rows, or adds them in the wrong order, the whole thing breaks and the drag handles don't show.

Steps to reproduce

1. Ensure there are at least 2 vocabularies
2. Comment out \Drupal\taxonomy\VocabularyListBuilder::buildRow()
3. Go to admin/structure/taxonomy

There are no drag handles!

Further investigation: in Drupal\Core\Entity\DraggableListBuilderTrait::buildRow() add a cell after the weight:

      $row['cell'] = [
        '#markup' => 'A CELL',
      ];

Reload and the table is still broken.

Now move the cell so it comes BEFORE the weight cell, and it works!

It seems that whatever is adding the drag handles is very particular about what it needs, and needs a cell that is NOT the entity operations to come first (but what's wrong with the operations that it doesn't like??)

This should:

a. Be documented on the trait
b. There should be some sort of warning to tell developers what they've done wrong

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Entity 

Last updated about 16 hours ago

Created by

🇬🇧United Kingdom joachim

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

Comments & Activities

Production build 0.71.5 2024