Skip to content
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

Using re-order on a numerical collection produces inverted results if collection's default sort isn't ASC #2324

timichango opened this issue Jan 8, 2019 · 3 comments


None yet
2 participants
Copy link

commented Jan 8, 2019

Describe the bug
I have a numerically-ordered collection. In folder.yaml, I've got sort_dir: desc applied.

When re-ordering using the reorder interface in CP — now that my default sort is inverted — the reorder interface doesn't produce the results you'd expect, since it doesn't appear to take into account the sort that's already applied.

Put another way: if my #14 entry (out of 14 entries) is shown in the top position, thanks to the desc. sort, and then I click reorder, doing any reordering (or, actually, no reordering at all), and then clicking 'save order', causes the reorder behaviour to effectively invert the currently displayed order, re-saving each entry with the correspondingly inverted number in sequence — #14 becomes #1, and so-on.

If I subsequently click re-order again (with the desc default sort), and re-save the order, it once again inverts. Ad-infinitum.

To Reproduce
Steps to reproduce the behavior:

  1. Add sort_dir: desc to the folder.yaml for a numerically ordered collection
  2. Go to the cp view for that collection
  3. Click on reorder
  4. Click on save order
  5. Watch with wonder as the sequence of entries gets inverted before thine eye-orbs
  6. Click on reorder again / click on save order again / behold another inversion of reality

Expected behavior
Seems that the 're-order' interface assumes that whatever's in visual position 1,2,3,etc. should get the order number 1,2,3,etc. — rather than getting an order number based on its relative numerical sequence to the adjacent entries, and/or the sort being displayed. Ideally, reordering should be context-sensitive to the order/sort that's displayed when reorder is invoked, and make ordering adjustments relative to that state, rather than in an ascending numerical order based on absolute visual position (eg. if the current sort is desc, then reordering enumeration should reflect this).

At present, having a descending default order for a numerical collection makes reordering extremely difficult (or at least requires some significant reording acrobatics on the part of the user).


Environment details (please complete the following information):

  • Statamic Version 2.11.4
  • Fresh Install or Upgrade: upgrade from 2.11.3
  • OS: macOS 10.13.6
  • Browser: chrome
  • Web Server: valet
  • PHP Version: PHP 7.2
  • Addons installed: Spock, CacheManager, Sally

Additional context
This issue makes me wonder if the same/similar behaviour is reproducible with pages as well — but I haven't explored this yet.

@timichango timichango closed this Jan 8, 2019

@timichango timichango reopened this Jan 8, 2019


This comment has been minimized.

Copy link

commented Jan 8, 2019

Accidentally closed — now repoened.


This comment has been minimized.

Copy link

commented Jan 8, 2019

Further observations: this isn't relegated to happening with an overridden default sort, it seems — if I comment out my desc sorting parameter in folder.yaml, refresh, and then manually invert the order sort to desc (I've got an order column set in folder.yaml), then click reorder, then save order, the same behaviour is observed.

Similarly, sorting by title, and then enacting the same reorder/save order routine, causes the entries to all wind up enumerated alphabetically, in whatever sort direction (asc/desc) the title sort was applied. Which is mildly bonkers.

Seems like at a minimum, in the context of a numerical collection, reorder should apply a numerical sort, upon its invocation, that corresponds to its assumptions about ordering enumeration... and which would be ideally be sensitive to any default sort override configurations in folder.yaml (and then enumerate accordingly).


This comment has been minimized.

Copy link

commented Feb 21, 2019

For next release, when you click "reorder", the items will first be sorted by the order key so you will see the real order. Sorting by column headers will be disabled while in reorder mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.