Problem/Motivation

When you create a menu link content from UI pointing to "/node/ID", it gets saved as "internal:/node/ID". When you later go to the node edit form, at the menu settings, it says "Not in menu".
If you create the menu link content from the UI using the node autocomplete, it gets saved as "entity:/node/ID", then the menu link is found and editable from the node edit form.

Steps to reproduce

- Create a node using the node creation form
- Create a menu link content using the UI pointing to /node/ID
- Go to edit the node created in the first step
- Note that, at the menu settings, it says "Not in menu"

Proposed resolution

Taking a look at the code, seems like the function responsible from returning the route candidates is menu_ui_get_menu_link_defaults() from the menu_ui module (moved at main branch to \Drupal\menu_ui\MenuUiUtility). The uri candidates were introduced in the issue #3499181: Disallow saving the current default revision as a non-default revision. I was trying to figure out if there a reason for excluding "internal:/node/ID" but couldn't figure out, neither possible side effects, but feedback is welcomed.

The proposed solution is including "internal:/node/ID" in the candidates. An alternative solution, probably cleaner but more expensive and complex, would be transforming /node/ID or /my-alias to entity:/node/ID during the saving process of a menu link content.

Remaining tasks

- patch
- review
- test

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

Issue fork drupal-3586428

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

akalam created an issue. See original summary.

akalam’s picture

Status: Active » Needs review
akalam’s picture

Version: main » 11.x-dev
akalam’s picture

Issue summary: View changes
idebr’s picture

Version: 11.x-dev » main
Status: Needs review » Needs work
Issue tags: +Need tests

Great find!

Can you add test coverage for this issue?