#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: |
Description
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 ) t.find('.is-submenu').hide(); }); }
Totally minor, but figured I would bring it up.
Attachments (2)
Change History (12)
#4
@
8 years 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.
Robert
#6
@
8 years 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:
- before the patch: https://cl.ly/0X3R1e1M3z32/screencast_2016-08-31_11-46-05.mp4
- after the patch: https://cl.ly/3T1g0e2M3y0y/screencast_2016-08-31_11-48-57.mp4
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.
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.