I had a problem with multiple sort containers being added around sortable markup - each box had 3 <div class="panels-ipe-sort-container" /> tags around them. The effect of this was to have ghost sort containers appearing when dragging my sortable content, and 'drop' action not succeeding. No idea (yet!) what causes the three calls to createSortContainers, but I've created a patch to add in a check when adding a sort container that makes sure the parent's class is not .panels-ipe-sort-container.

Anyone else have a similar issue?

Comments

Letharion’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry, but I don't quite understand in which situation this happens. Maybe a screenshot could help?

merlinofchaos’s picture

Hm yeah, I've never had this happen myself. Maybe something weird with behaviors?

joe-b’s picture

StatusFileSize
new42.79 KB
new85.56 KB

Sorry, but I don't quite understand in which situation this happens.

No, neither do I yet, just that it's happening in our setting (intranet, so I can't point you to it, sorry). Frustrating, I know. I was putting this out there to find out if anyone else has similar problems, really.

Maybe a screenshot could help?

Here's a couple of screenshots, then - 1st of the markup being generated, and 2nd of the effect, with ghost sort containers floating with the drag-and-drop motion.

Letharion’s picture

Can you reproduce it on a clean install?

Letharion’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
yched’s picture

Version: 6.x-3.9 » 7.x-3.x-dev
Status: Closed (cannot reproduce) » Active

Sorry to reopen an old issue, but this is the closest I found to the issue I'm seeing.

The problem is that panels_ipe.js's createSortContainers() seems to only work if the markup spitted by the region style directly consists of the draggable panes, with no surrounding markup.

If the region style adds wrapping markup, then:
- if the region is not empty, createSortContainer() produces *two* '.panels-ipe-sort-container ' divs.
- then bad things happen when you add a new block through IPE: the markup for the new block gets inserted twice (one for each 'panels-ipe-sort-container'),
- then on "Save" you get an "Integrity constraint violation: Duplicate entry for key PRIMARY: INSERT INTO {panels_pane}" error.

Easily reproduced with "list" region style, or any custom style created with Stylizer :
- Take a region that's not empty (or add a custom block in it, save)
- Switch the region style to "List / unordered", and save.
- Using the IPE, add a new custom block to the region --> The markup appears twice, once in the ul/li, once above
- Save --> "Integrity constraint violation" error.

yched’s picture

Status: Active » Needs review
StatusFileSize
new2.69 KB

Attached patch seems to do the trick :

- Makes sure that createSortContainers() targets the right 'panels-ipe-portlet-marker' (there is one per region + one per pane in the region, we want the one of the region), and thus does not create duplicate 'panels-ipe-sort-container' divs for each region

- After a new pane is created, makes best effort to insert the HTML at the "right" place within the wrapping markup for the region - that is, before the 1st existing pane in the region. If the region was empty so far, there's no way to find that "right" sport, insert it as a child of the 'panels-ipe-sort-container' div like current code does.
Won't always be perfect, for example, in the case of the "list / unordered" region style, the new pane will appear just before the former first pane but within the same <li>. But works fine for Stylizer or other 'simple div' based Styles.

Note: patch is against -dev, but was developped and tested against 7.x-3.3 only. Dunno if things have changed a lot in this area since then...

yched’s picture

Clearer explanation:

   this.createSortContainers = function() {
     $('div.panels-ipe-region', this.topParent).each(function() {
-      $('div.panels-ipe-portlet-marker', this).parent()
+      $(this).children('div.panels-ipe-portlet-marker').parent()
         .wrapInner('<div class="panels-ipe-sort-container" />');

Current code works with "default" region style, because while there are several $('div.panels-ipe-portlet-marker', this), they are all siblings and thus have the same parent --> wrapInner() operates on a jQuery set with a single element, 'panels-ipe-sort-container' is added once.
That's not true anymore for region styles with wrapping markup: there are several $('div.panels-ipe-portlet-marker', this) with different parents --> several 'panels-ipe-sort-container' end up being created for the region.

hefox’s picture

Fixed the issue for me

populist’s picture

I tested this patch a bit with Panopoly and things generally seem to work right. Anyone else have any feedback?

mpotter’s picture

Status: Needs review » Reviewed & tested by the community

This patch is also being used and is working in Open Atrium 2.

asgorobets’s picture

Patch from #7 also resolved the issue for me. Thanks yched!

japerry’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

  • Commit 63cf629 on 7.x-3.x, 8.x-3.x by japerry:
    Issue #1354572 by yched: IPE - multiple JS sort containers