Make WordPress Core

Opened 3 years ago

Last modified 2 months ago

#57170 new defect (bug)

Fix invalid menu-item-parent

Reported by: azaozz's profile azaozz Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Customize Keywords: reporter-feedback has-patch
Focuses: Cc:

Description

Follow up to #56926.

There seems to be a bug in the Customizer that may set $menu_item->menu_item_parent to be the same as $menu_item->ID. Steps to reproduce: https://core.trac.wordpress.org/ticket/56926#comment:21. There also seems to be a related JS error:

Uncaught TypeError: parentControl is undefined
    .../wp-admin/js/customize-nav-menus.js?ver=6.2-alpha-54642-src:2330

Attachments (2)

Screen Recording 2025-07-09 at 3.34.07 PM.mp4 (2.4 MB) - added by lakshyajeet 8 months ago.
Before the fix (reproducing the error)
Screen Recording 2025-07-09 at 3.35.44 PM.mp4 (2.4 MB) - added by lakshyajeet 8 months ago.
After the Fix

Change History (20)

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


3 years ago

#2 @mukesh27
3 years ago

  • Keywords needs-patch reporter-feedback added

Thanks @azaozz for the ticket!

This ticket was discussed during the recent bug scrub. It looks like it's unlikely that work will be done on this during the 6.2 cycle.

Is this still possible to land in 6.2, or should it be moved to Future Release for now?

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


3 years ago

#4 @costdev
3 years ago

  • Milestone changed from 6.2 to 6.3

This ticket was discussed in the bug scrub and it was agreed to move this ticket to 6.3.

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


3 years ago

#6 @oglekler
3 years ago

  • Milestone changed from 6.3 to 6.4

Due to lack of activity and a patch I am moving this ticket to the 6.4 milestone.

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


3 years ago

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


2 years ago

#9 @oglekler
2 years ago

This ticket was discussed during a bug scrub. Last chance for this ticket :)

Because we already moved it a couple of times, the next step for it is Future releases.

Add props to @mukesh27

#10 @oglekler
2 years ago

  • Milestone changed from 6.4 to 6.5

We have no patch and solving the issue can be tricky, so I am moving this to 6.5.

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


2 years ago

#12 @audrasjb
2 years ago

  • Milestone changed from 6.5 to Future Release

As per today's bug scrub, we decided to move this ticket to Future Release to give it more time to get a patch.

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


8 months ago
#13

  • Keywords has-patch added; needs-patch removed

Trac ticket: https://core.trac.wordpress.org/ticket/57170

---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

### Before:

https://github.com/user-attachments/assets/4c033e42-9553-4295-b949-90e2797bae7f

### After:

https://github.com/user-attachments/assets/73d5d9e6-7898-464f-b2f3-9525408e62a3

@lakshyajeet
8 months ago

Before the fix (reproducing the error)

#14 @oglekler
7 months ago

@azaozz please check the patch. It looks like a strait forward solution.

@azaozz commented on PR #9222:


7 months ago
#15

Looks good here. Thanks for the videos :)

#16 @oglekler
7 months ago

  • Keywords needs-testing added

This ticket was mentioned in Slack in #core-test by oglekler. View the logs.


7 months ago

#18 @huzaifaalmesbah
2 months ago

  • Keywords needs-testing removed

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/9222

Steps to Reproduce or Test

  1. Go to Appearance ▸ Customize ▸ Menus.
  2. Open the browser developer tools and switch to the Console tab.
  3. Create a new menu.
  4. Add multiple menu items to the menu.
  5. Set one menu item as a submenu (child) of another menu item.
  6. Click Publish, then reload the page.
  7. Open Appearance ▸ Customize ▸ Menus again and select the same menu.
  8. Remove the parent menu item of the submenu item.
  9. Reassign the submenu item to a parent again using the menu item settings in the right panel.
  10. Click Publish, then reload the page.
  11. Open the menu again in the Customizer.
  12. Select the submenu item and click Reorder.
  13. Press the left arrow key to move the submenu item out of its parent.
  14. Observe the browser console.

Expected Results

✅ No JavaScript errors should be logged in the browser console.
✅ The submenu item should be successfully reordered and moved out of its parent.

Environment

  • WordPress: 7.0-alpha-61215-src
  • PHP: 8.2.29
  • Server: nginx/1.29.4
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 143.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty 3.0
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Actual Results

Before applying the patch

❌ A JavaScript error is logged in the browser console:

  Uncaught TypeError: Cannot read properties of undefined
  customize-nav-menus.js?ver=7.0-alpha-61215-src

❌ The submenu item cannot be reordered using the left arrow key.

After applying the bugfix patch

✅ No JavaScript errors are logged in the console.
✅ The submenu item can be reordered correctly.

Screenshots

Before Apply Patch After Apply Patch ✅
https://i.ibb.co.com/fzYmrTZr/Huzaifa-20260116184406.png https://i.ibb.co.com/gZ1k5hL0/Huzaifa-20260116191124.png
Note: See TracTickets for help on using tickets.