The tabledrag "Show Row Weights" button is missing

Created on 26 April 2023, over 1 year ago
Updated 11 July 2023, about 1 year ago

The tabledrag "Show Row Weights" button does not appear, although other tabledrag functionality appears to work correctly.

#3188251: Cannot read property 'html' of undefined and #3209773: this.$toggleWeightBUtton is undefined were committed around the same time and released with version 3.24. The changes had to be integrated together since they affected the same code. Unfortunately, the changes conflicted slightly and incorrect modifications were made to one of the patches. Unless I'm mistaken, the button markup is set in js/misc/tabledrag.js line 181 and then is immediately overwritten on line 188.

...
    // Add a link before the table for users to show or hide weight columns.
    self.$toggleWeightButton = $(Drupal.theme('btn-sm', {
      'class': ['tabledrag-toggle-weight'],
      'data-drupal-selector': ['tabledrag-toggle-weight'],
      title: Drupal.t('Re-order rows by numerical weight instead of dragging.'),
      'data-toggle': 'tooltip'
    }));

    self.$toggleWeightButton = $('[data-drupal-selector="tabledrag-toggle-weight"]');
...

It looks like line 188 was an attempt in #3188251 to replicate what was done in the Drupal Core tabledrag.js where the button is themed with a wrapper. The button then has to be found within that wrapper in order to apply the onClick event, see https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/misc/tabled.... Except that isn't even necessary here because the button that Bootstrap's tabledrag.js creates doesn't have a wrapper. Thus, the solution to this problem should be to simply delete line 188, which works to solve the problem for me.

Patch incoming.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States dcam

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

Comments & Activities

Production build 0.71.5 2024