-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorder function #931
Reorder function #931
Conversation
Updated reorder function to account for when there are duplicate Sort values
…Element and Element_Live table
What are we trying to fix here? From what I'm reading, the existing code already supports the situation where the current sort order matches the intended sort order, as it will decrement the sort of every element with a sort less than or equal to it. I really don't like code that introduces an arbitrary number of queries - and this code has been specifically written to avoid more than one. |
@ScopeyNZ I came across an issue where elements under the same ParentID have duplicate Sort value, and I can't seem to replicate that anymore. To fix existing records, I've created a sort all elements function. Please advise if there's a better way of doing this, thanks. |
I don't really like the idea of a side effect of somebody reordering their elements is a long running "fix the whole thing", that also doesn't have any guarantee of respecting the order they chose. If there's a bug in this code which will mess up the sort order then we should address that, but other than that, I'm thinking we shouldn't have the code be concerned with garbage data. |
This just came up in a different context, possibly a bit more information about the bug at play: #849 (comment) |
Just adding my $0.02. As Bryn mentioned, I experienced this issue here #849 (comment) I think we could avoid a lot of these instances simply by making sure that we don't set a There could be some other instances where a block gets a duplicate |
@brynwhyman @chrispenny Just found out that this solution is only partially working 😂 , it doesn't work when when have 2 elements with sort value of Another thing I found is that the duplicated sort value is caused by when an Elemental Block is archived and then restored |
@Jianbinzhu good find with the archive restoration. Based on @ScopeyNZ's comment, this would be an area where we would want to fix the "restoration process" itself. EG: Maybe we have it set the |
In regards to the sort order on archive/publish. I think it would make sense to clear the sort order value when a block is archived. I'll raise an issue for sort being broken as elements are restored from the archive. WRT this PR, I'm going to close it as I don't think it's the solution we're looking for. Thanks for the help getting to the bottom if this issue! |
Updated reorder function to account for when there are duplicate Sort values of elements within an ElementalArea