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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3356675-4.patch | 396 bytes | sharayurajput |
| #2 | 3356675-2.patch.txt | 406 bytes | dcam |
Comments
Comment #2
dcam commentedHere's a patch that simply removes the line that overwrites the button variable.
Comment #3
sharayurajput commentedPatch is not able to apply, its showing error -
error: corrupt patch at line 8
so need to work
Comment #4
sharayurajput commentedproving patch for this
Comment #5
sharayurajput commentedPlease review this patch
Comment #6
dcam commentedI 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.
Comment #8
shelane