No Code Attached Yet bug
avatar muddygs
muddygs
23 Sep 2022

Steps to reproduce the issue

(a) Use a draggable list (class="js-draggable") such as com_menus (src/Model/ItemsModel.php). It is possible to drag a submenu item to a higher-level menu item, but the moved items is not associated with the higher-level menu item.

(b) Incorrect use of boolean

Expected result

  • MENU 1
    • MENU 1.1
    • MENU 1.2
  • MENU 2

Actual result

Can drag MENU 1.1 to under MENU 2 but MENU 1.1 is still under MENU 1 after reload. In J3, dragging was restricted within direct siblings only, so if that's still the way, then moving item under MENU 2 should not be permitted.

System information (as much as possible)

Linux Firefox 105.0 (64-bit)
Joomla 4.2.2

Additional comments

In "accepts", if (isNested) { is not valid since isNested is a string (code block always true). Could revise to "true" == isNested. Or, fix upstream Joomla.getOptions to convert true/false strings to boolean.

This isn't perfect, but it keeps the sibling-only concept by checking that the sibling is not presently mirrored (i.e, not direct sibling) by checking for "gu-mirror" class attribute value. gu-mirror class is explained in dragula documentation.

media/system/js/draggable.js:

    accepts(el, target, source, sibling) {
      if ( "true" == isNested ) { //patch1
        if ( sibling.classList.contains("gu-mirror")) return false; //patch2 (need same for "false" isNested condition?)

        if (sibling !== null) {
          return sibling.dataset.draggableGroup && sibling.dataset.draggableGroup === el.dataset.draggableGroup;
        }
        return sibling === null || sibling && sibling.tagName.toLowerCase() === 'tr';
      }
      return sibling === null || sibling && sibling.tagName.toLowerCase() === 'tr';
    },

First submission here, so I hope I met community standards and requirements with this submission.

avatar muddygs muddygs - open - 23 Sep 2022
avatar muddygs muddygs - change - 23 Sep 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 23 Sep 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Sep 2022
avatar joomdonation
joomdonation - comment - 14 Nov 2022

@Fedik or @dgrammatiko Could one of you two look at the suggested change to see if it is valid? If Yes, we can ask @muddygs to make PR . Thanks !

avatar Fedik
Fedik - comment - 14 Nov 2022

Moving element on higher level it not only javascript, but also require php changes to handle new/old parent and related changes to keep a tree in shape.
So not so easy.

avatar Hackwar Hackwar - change - 17 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 17 Feb 2023
avatar Hackwar Hackwar - change - 30 Mar 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-03-30 21:34:40
Closed_By Hackwar
avatar Hackwar Hackwar - close - 30 Mar 2024
avatar Hackwar
Hackwar - comment - 30 Mar 2024

I've checked this issue again with Joomla 4.4 and it seems as if the bug has since been fixed. I also looked into the code and the value has been changed to a true boolean it seems. Thank you for reporting this issue. Closing for now. :-)

Add a Comment

Login with GitHub to post a comment