Make WordPress Core

Opened 11 months ago

Closed 10 months ago

Last modified 9 months ago

#63059 closed defect (bug) (fixed)

JS Warning in navigation menus when removing an item

Reported by: joedolson's profile joedolson Owned by: joedolson's profile joedolson
Milestone: 6.8 Priority: normal
Severity: normal Version: 6.7
Component: Menus Keywords: has-patch
Focuses: javascript Cc:

Description

When removing an item from nav menus, an uncaught TypeError is thrown: "menus.updateParentDropdown is not a function". Thrown by the removeMenuItem method, where it appears that the function is attached to the wrong object.

Introduced in [59265].

Milestoning for 6.7.3 if that occurs.

Change History (15)

#1 @joedolson
11 months ago

  • Owner set to joedolson
  • Status changed from new to accepted

#2 @abcd95
11 months ago

Hi @joedolson and thanks for reporting this issue.

I think the problem occurs because, in nav-menu.js, the code is incorrectly calling the updateParentDropdown() and updateOrderDropdown() methods on the menus object instead of on the proper jQuery object.

See here -

https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/nav-menu.js#L1765
https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/nav-menu.js#L1224

The fix is straightforward - we need to call these methods on the menu container object ($( '#menu-to-edit' ))

I'll submit a PR with this fix shortly which in my testing resolves the console errors.

Last edited 11 months ago by abcd95 (previous) (diff)

This ticket was mentioned in PR #8464 on WordPress/wordpress-develop by @abcd95.


11 months ago
#3

  • Keywords has-patch added; needs-patch removed

Trac ticket:

@audrasjb commented on PR #8464:


11 months ago
#4

Thanks, I tested the patch on my side and I can confirm it fixes the issue.

#5 @joedolson
11 months ago

  • Keywords commit added

Thanks for the quick action, @abcd95! LGTM.

#6 @joedolson
11 months ago

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

In 59950:

Menus: Fix JS Warning when removing menu items.

Move the updateParentDropdown and updateOrderDropdown methods to be called on the jQuery menu object instead of on the menus translations object.

Props joedolson, abcd95, audrasjb.
Fixes #63059.

#7 @joedolson
11 months ago

  • Keywords dev-feedback added; commit removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Re-opening for 6.7.3, although that seems like a low probability milestone at this point.

#8 @jorbin
10 months ago

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

In 59977:

Menus: Fix JS Warning when removing menu items.

Move the updateParentDropdown and updateOrderDropdown methods to be called on the jQuery menu object instead of on the menus translations object.

Reviewed by jorbin.
Merges [59950] to the 6.7 branch.

Props joedolson, abcd95, audrasjb.
Fixes #63059.

#9 @Presskopp
9 months ago

  • Keywords dev-feedback removed

#10 @phanduynam
9 months ago

Is the issue resolved? If so, please close it.

#11 @jorbin
9 months ago

@phanduynam The status is right next to the ticket number at the top of the page. This has been closed for 5 weeks.

This ticket was mentioned in Slack in #core by sergey. View the logs.


9 months ago

#14 @phanduynam
9 months ago

@jorbin closed but why do I still see it here?
https://core.trac.wordpress.org/tickets/minor

#15 @Presskopp
9 months ago

.. because of the milestone, here you can see it's closed, but still marked as 6.7.3: https://core.trac.wordpress.org/milestone/6.7.3

#16 @joedolson
9 months ago

  • Milestone changed from 6.7.3 to 6.8

Moving to the 6.8 milestone, which is where it actually shipped.

Note: See TracTickets for help on using tickets.