Opened 10 years ago

Closed 6 years ago

#4825 closed bug (worksforme)

sortable doesnt handle td/th elements correctly

Reported by: markw65 Owned by:
Priority: minor Milestone: 2.0.0
Component: ui.sortable Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

If I make a "tr" sortable, I can drag the td or th elements around, but its very hard to make them actually sort (you have to drag the element to the correct location, and then wave it up and down!)

After digging into the code for a while, I realized its because it assumes the sort is vertical, unless at least one element has "float:left" or "float:right" style. Note that this is the case even if you set "axis":"x".

I tried applying float:left to the th cells, but that caused all sorts of issues. So instead I tried:

$("#myrow").sortable().data("sortable").floating = true;

And it worked perfectly - but of course it depends on the internals of sortable.

I think it would be good if sortable recognized that if the container is a tr, the elements are going to be dragged horizontally; and also that if "axis":"x" is set, the elements are going to be dragged horizontally(!).

I have an example page at http://maps.myosotissp.com/bugs/sort.html, showing the broken, and fixed behavior.

Change History (4)

comment:1 Changed 10 years ago by Scott González

Milestone: TBD1.8

comment:2 Changed 9 years ago by markw65

Not sure if this needs a separate bug, but non-visible td/th cells aren't handled correctly in ie8.

The problem is that such cells end up with the dimensions of the row, and so _intersectsWithPointer incorrectly determines that the pointer is over the hidden cell.

This "feature" of ie8 also affects the :hidden and :visible selectors (I've filed bug 5342 against jquery). But even when that bug is fixed, _intersectsWithPointer will still need to check that style.disply != "none" (or sortable could filter out hidden items when its initialized).

I've put an example at http://maps.myosotissp.com/bugs/sort2.html

When IE8 runs in IE7 mode, the bug does not appear. http://maps.myosotissp.com/bugs/sort.html?ie7=1 adds the <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> to the page header, and works around the bug.

comment:3 Changed 6 years ago by Scott González

Milestone: 1.9.02.0.0

comment:4 Changed 6 years ago by mikesherov

Resolution: worksforme
Status: newclosed

Thanks for taking the time to contribute to the jQuery UI project! I can no longer reproduce the issue using the latest jQuery and jQuery UI. http://jsfiddle.net/SHUaS/1/

If you can still reproduce it, please feel free to reply to this ticket with a test case showing the problem. Thanks!

Note: See TracTickets for help on using tickets.