Make WordPress Core

Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#37846 closed defect (bug) (fixed)

Minor Parent Menu Item Deletion 'sub item' Issue

Reported by: rnoakes3rd Owned by: adamsilverstein
Milestone: 4.7 Priority: normal
Severity: trivial Version:
Component: Menus Keywords: has-patch commit has-screenshots
Focuses: ui, javascript, administration Cc:


When a top-level parent nav menu item is deleted in the admin, the direct children still display the 'sub item' text. After some quick research, I found that the $.fn.shiftDepthClass (line 82 of /wp-admin/js/nav-menu.js) function could be changed a bit to resolve this:

shiftDepthClass : function(change) {
	return this.each(function(){
		var t = $(this),
			depth = t.menuItemDepth(),
			new_depth = depth + change;
		t.removeClass('menu-item-depth-'+ depth )
			.addClass('menu-item-depth-'+ (new_depth) );
		if ( new_depth == 0 )

Totally minor, but figured I would bring it up.

Attachments (2)

37846.patch (750 bytes) - added by rnoakes3rd 21 months ago.
Patch for the unminified /wp-admin/js/nav-menu.js file.
37846.2.patch (763 bytes) - added by adamsilverstein 21 months ago.

Download all attachments as: .zip

Change History (12)

#1 @rnoakes3rd
21 months ago

  • Severity changed from normal to trivial

#2 @swissspidy
21 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.7

Hey there,

Welcome to WordPress Trac and thanks for suggesting a solution right away! It would be great to have that snippet as a patch so we could more easily test it.

Are you familiar with working with patches? There's a good handbook entry about creating and testing patches.

#3 @swissspidy
21 months ago

  • Version 4.6 deleted

21 months ago

Patch for the unminified /wp-admin/js/nav-menu.js file.

#4 @rnoakes3rd
21 months ago

Thank you, Pascal! I have attached the patch. I change the code a bit to better follow the coding standards used throughout the file. Please let me know if there are any issues.


#5 @rnoakes3rd
21 months ago

  • Keywords has-patch added; needs-patch removed

#6 @adamsilverstein
21 months ago

  • Owner set to adamsilverstein
  • Status changed from new to assigned

@rnoakes3rd Thanks for the patch, works great!

I tested this and verified it fixes the issue you noted.

Here is a screencast as a visual record:

I also tested the patch with multiple level menus and everything worked as expected.

ps. Please note that for consistency we generate patches one folder up from where you where, the trunk folder of the WordPress development repository. I am uploading an updated patch. I also added a bit more whitespace inside parentheses (only for the code we are touching and despite the nearby non spaced code), following the WordPress JavaScript coding standards.

#7 @adamsilverstein
21 months ago

  • Keywords commit has-screenshots added

#8 @rnoakes3rd
21 months ago

Thank you for the info, Adam! I'm glad the patch worked. Looking at the code, those parentheses could probably be removed since there is no math occurring there anymore, but they aren't hurting anything. More of an oversight on my part :)

#9 @swissspidy
21 months ago

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

In 38612:

Menus: Remove 'sub item' label when removing the sub item's parent.

Props rnoakes3rd, adamsilverstein.
Fixes #37846.

#10 @swissspidy
21 months ago

In 38613:

Menus: Use strict comparison for the condition added in [38612].

See #37846.

Note: See TracTickets for help on using tickets.