Problem/Motivation

Drag and drop table item in multi-levels hierarchy is broken. For example, in Menu manage page we cannot drag a `child menu item with child items` to parent level.

What we expected:

(D7 and before #2154475: Convert position selectors to be compatible with with jQuery native-API selector patch)

What we get in D8

(D8-GIT-HEAD)

Step to reproduce:
1. Go to /admin/structure/menu/manage/admin
2. Trying to drag a menu tree with 2 or 3 levels to parent ( moving to left and right ) (@see above GIF)

`:eq(0)` is not equivalent to `.eq(0)`
`:first` is not equivalent to `.first()`
https://jsfiddle.net/4tv4eh6h/

** Note that it can't drag and drop parent-child trees in some condition and the same errors occurred on D7. Please compare it with D7 when you review the patch.

Proposed resolution

This error introduced by #2154475: Convert position selectors to be compatible with with jQuery native-API selector. Here's fixing to make it work as before patch.

Remaining tasks

- Review patch
- Create a follow up issue: At some cases, it may trying to match `.first()` but misused `:first`

User interface changes

-

API changes

-

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

droplet’s picture

Issue summary: View changes
droplet’s picture

Issue summary: View changes
aburrows’s picture

Status: Needs review » Closed (cannot reproduce)

This works as intended in the latest release of 8.x.

droplet’s picture

Status: Closed (cannot reproduce) » Needs review
FileSize
5.76 KB

I re-checked and it still doesn't work. Just moving one item not whole tree

droplet’s picture

Issue summary: View changes
droplet’s picture

Issue summary: View changes
FileSize
26.8 KB
38.22 KB
droplet’s picture

Issue summary: View changes
droplet’s picture

Issue summary: View changes
droplet’s picture

Issue summary: View changes
droplet’s picture

Issue summary: View changes
nod_’s picture

Status: Needs review » Reviewed & tested by the community

Sorry for the delay in reviewing that, wanted to take the time to see where selectors were wrong.

Patch works, and from the looks of it we'd want to use :first-of-type all over the place where we used .eq(0).

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed dcf9ab4 and pushed to 8.0.x. Thanks!

Thanks for providing https://jsfiddle.net/4tv4eh6h/ and the screencasts - makes the bug easy to see.

  • alexpott committed dcf9ab4 on 8.0.x
    Issue #2489826 by droplet: tabledrag is broken
    
hchonov’s picture

Status: Fixed » Active

This patch introduced a problem which was not there before it!

$form['table_a'] = ['#type' => 'table'];
$form['table_a']['row1'] = ...;
$form['table_a']['row1']['column_1'] = .....;
$form['table_a']['row1']['column_1']['table_b'] = ['#type' => 'table'];

Now all the rows of table_b will get a double tabledrag-handle, when makeDraggable is running.
First from the run for table_a and then from the run for table_b!

Until the patch was commited everything was functioning properpy for this kind of nested tables....

And at least this problem is in exchanging the row

$item.find('td').eq(0).prepend(handle);

with

$item.find('td:first-of-type').prepend(handle);

Excuse me for reopening the issue, but this is where the problem got in core.

droplet’s picture

can you post a patch/module with full testing code ?

hchonov’s picture

Status: Active » Closed (duplicate)

created a follow issue for this problem as requested by @alexpott : #2499605: tabledrag is adding tabledrag-handle twice for nested tables

hchonov’s picture

Status: Closed (duplicate) » Fixed

Changing status back to fixed. Please see the new issue.

alexpott’s picture

Status: Fixed » Closed (fixed)

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