Deleted pages not removed from menu

Why aren’t pages that I delete removed from navigation menus automatically? They return a 404 for any visitor that clicks it.

Looking at a few core WordPress.org tickets:

  • https://core.trac.wordpress.org/ticket/32820
  • https://core.trac.wordpress.org/ticket/26795
  • https://core.trac.wordpress.org/ticket/13822

Seems like the best user flow would be to remove the menu item at the same time as removing the page (or post). Are there reasons to persist the menu item if the content doesn’t exist any more?

Steps to repeat (testing on both a WordPress.com site as well as a self-hosted site on Pressable running trunk).

1. Create a menu, add pages to it.
2. Check the option “Automatically add new top-level pages to this menu” on.
3. Create some pages. Watch them appear magically in the menu, on the front-end — in Customizer Menus, and in wp-admin Menus.
4. Now, delete a page.
5. I’d expect it to be gone from my menu! It’s not. Still there.

#menus #flow #delete #trash #page #navigation