In Users > Fields create 3 custom fields: test 1, test 2, test 3 (e.g. type text)
when looking in the fields table you can see that all of them have set the ordering field to 0
now click on the sort column header to start sorting
drag test 1 to position 2
the displayed sort order is now:
test 2
test 1
test 3
now press f5 to refresh the screen
the sort order now is:
test 2
test 3
test 1
the values in the ordering field should be set to the correct sort order:
test 1 > 2
test 2 > 1
test 3 > 3
the values in the ordering field are not set to the correct sort order
test 1 > 3
test 2 > 1
test 3 > 2
tested with todays (2021-05-14) nightly
php 8.0.5
mysql 8.0.25
confirmed issue
Confirmed, applies to core and also third-party extensions
The problem is that the dragged element is always POSTed as the last one having the max order value
order[]: 16
cid[]: 30
@Fedik or @dgrammatiko Could you please take a look? It seems the dragged row is also counted, so on this line https://github.com/joomla/joomla-cms/blob/4.0-dev/build/media_source/system/js/draggable.es6.js#L54 , rows
contains more than one element than it should
Change this line https://github.com/joomla/joomla-cms/blob/4.0-dev/build/media_source/system/js/draggable.es6.js#L64 to
for (i = 0, l = rows.length - 1; l > i; i += 1) {
would fix the issue. But I guess it is not the right fix.
Labels |
Added:
J4 Issue
?
|
@joomdonation looking good, probably I should go back to elementary school and relearn counting
@dgrammatiko No, your original code looks good. The issue we are having here is somehow, related to how dragula
works. If we have table with 3 rows for example, that querySelectorAll methods 4 rows. I can only guess that dragula create one extra element which is used for drag and drop and that's the reason querySelectorAll return one extra row.
In short, you do not have to go back to elementary school :D.
The issue we are having here is somehow, related to how dragula works.
Yes and no, the function getOrderData
is getting the elements on the drop
event which of course will include the extra DOM element that draggula is creating for the dragging effect. One option is to have the length shortened by one, as you're doing, or query the rows at the beginning of the script (when there's no shadow/extra element). Both ways are fine
Thanks @dgrammatiko . I tried to query the elements from outside, for some reasons, it is not working. So I choose the easy way by shortened by one, it works. Please test PR #33909.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-05-16 04:51:55 |
Closed_By | ⇒ | joomdonation | |
Labels |
Added:
?
Removed: ? |
confirmed - something weird going on there