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.

CommentFileSizeAuthor
#4 3356675-4.patch396 bytessharayurajput
#2 3356675-2.patch.txt406 bytesdcam

Comments

dcam created an issue. See original summary.

dcam’s picture

Status: Active » Needs review
StatusFileSize
new406 bytes

Here's a patch that simply removes the line that overwrites the button variable.

sharayurajput’s picture

Status: Needs review » Needs work

Patch is not able to apply, its showing error -
error: corrupt patch at line 8
so need to work

sharayurajput’s picture

Assigned: Unassigned » sharayurajput
StatusFileSize
new396 bytes

proving patch for this

sharayurajput’s picture

Assigned: sharayurajput » Unassigned
Status: Needs work » Needs review

Please review this patch

dcam’s picture

I copied and pasted the patch text from a remote server into Windows. The Windows line ending formatting may have caused the problem. Sorry about that.

  • shelane committed b53b4044 on 8.x-3.x authored by dcam
    Issue #3356675 by sharayurajput, dcam: The tabledrag "Show Row Weights"...
shelane’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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