Relationship order is not preserved when saving a child
When you have a relationship between two content types and edit + save one of the children, this child moves to the last position in the relationship order. This can be reproduced on the demo site by following the steps below:
Expected Behavior
The order should not change. It should only change if you explicitly drag & drop the child to another place.
Current Behavior
Child content seems to be sorted on modDate automatically. It looks like this won't happen with older content (that is perhaps created before a dotCMS upgrade?)
Known Workarounds
Manually dragging the children to the correct order after each change of a child.
Steps to Reproduce (for bugs)
On demo.dotcms.com:
- Create a new 'Blog' contentlet
- Save the Blog and re-open it
- Relate three new Comments
- Remember the order of the comments as seen in the Blog content
- Edit the first comment and save it
- The first comment has now moved to the last place
Context
We have a widget that contains child content to render columns on a page. After changing a column, it moves to the right. We have to change it to the correct location each time we edit one of the columns.
Your Environment
- dotCMS version used: 3.7.1 (but can also be reproduced in 4.1.0)
- Browser Name and version: Chrome 58
- Operating System and version: Windows Server 2012 R2
- Application Server and version: Bundled Tomcat
- Java Brand and version: Oracle Java 8u131
- Database and version: Postgres 9.6
- Application module (if apply):
A couple notes here, since I tried to reproduce this:
- We update and save child content items regularly on our own documentation and training content types without seeing this problem (I just tested it to verify).
- I just tried to reproduce this problem on the demo site (running 4.1) with both the Blog-Comment relationship (I followed the steps to reproduce above) and the LangingPage-Product relationship, and could not reproduce the problem with either of them.
So I'm not sure what may be causing the problem. I'm running also running Chrome 58. The demo site runs Postgres and Oracle Java I believe on Linux (though I'm not sure of the versions). So the only real difference seems to be the OS - though it seems unlikely that OS differences would cause this type of problem.
Thanks for your response. I have just tried it again and made a screencap. Maybe this will explain what I'm trying to do. At the end you'll see that I'm also unable to change the order using drag & drop.
We have also been using the relationships for quite some time now, and we have never faced this issue. Maybe it's a browser issue indeed, I will try it later today on Firefox to make sure that it's not my Chrome browser that's causing this.
Screencap: http://recordit.co/juztY2j1is
Edit: Just tested in Firefox, this gives me the same issues. I also tried it on another PC from another network, but I'm still able to reproduce the issue consistently. However, this time I didn't have the issue that you see at the end of the screencap. I was able to change the order using drag & drop.
One thing I noticed here is that after I drag the children in the correct order, the issue seems to be gone. So it seems that the issue will only occur if:
- The child content is new, without relationship to another parent
- The child content is created from the parent (-> Relate new content)
- The child content is not yet re-ordered (so not dragging them in the correct order)
It looks like the order on the relationship is not yet stored at first, and so it falls back to modDate. After re-ordering, the order gets stored and that solves the issue.
This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.