Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#13337 closed defect (bug) (fixed)

Menu item order isn't saved automatically

Reported by: Denis-de-Bernardy Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords:
Focuses: Cc:


Create a foo link in a menu. Then click the Add Home link button. Menu items are sorted as Home, foo.

Navigate away, and back. Menu items are now sorted foo, Home.

Attachments (1)

13337.1.patch (2.9 KB) - added by koopersmith 8 years ago.

Download all attachments as: .zip

Change History (7)

#1 @Denis-de-Bernardy
8 years ago

A similar bug occurs when you further toss in a category and a category. Adding cat and page results foo, home, cat, page; browsing away and back returns foo, page, home, cat.

#2 @Denis-de-Bernardy
8 years ago

Adding insult to injury:

  1. hitting the Save Menu button doesn't help. I added a further cat2, resulting in foo, page, home, cat, cat2; and then I hit the Save Menu button. This results in foo, page, cat2, home, cat.
  1. Drag and dropping menu items doesn't seem to make much of a difference either...

#3 @koopersmith
8 years ago

  • Summary changed from Menu order isn't saved when adding a home link to Menu item order isn't saved automatically

A lot of these problems tie into the draft menu item system: We have a draft state for menu items, but not a draft state for the menu as a whole. As a result, when a menu item is added (but not saved) it will be in a draft state (and appear on the backend, but not the frontend). When a menu is rearranged, however, the new positions cannot be saved until the user clicks "Save Menu". Auto-saving positions isn't feasible because saving the positions to the db causes the published menu items to rearrange on the frontend (not to mention the massive number of ajax requests it would require).

The smaller bug is that the JS should always update the menu item position data before the menu is saved (and only before the menu is saved, as that's the only time position data can be saved to the db anyway). A patch is attached to fix that.

We've planned to add an "unsaved" label to draft menu items to clear up some of the UX issues here. As for a solution to the first problem, I'd say that we should give draft menu items a position of -1 and automatically place them at the end of the menu.

8 years ago

#4 @nacin
8 years ago

Only save menu item positions on save. Had implications for draft items otherwise. see #13337, props koopersmith.


#5 @ocean90
8 years ago

Related: #12472

#6 @markjaquith
8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Seems to be fixed.

Note: See TracTickets for help on using tickets.