Problem/Motivation

Drupal nowadays includes a cool feature that allows you to autocomplete paths when adding menu links. Unfortunately the MenuLink Autocomplete field can only autocomplete paths for nodes, ignoring other content entities (e.g. taxonomy terms).

Steps to reproduce

  1. Create a node of whatever content type (e.g. basic page);
  2. Create a taxonomy term
  3. Go to https://yourdrupalsite/admin/structure/menu/manage/main/add
  4. Start typing in the "path" autocomplete field the title of the node you created in step 1: notice how the field nicely autocompletes the reference for you.
  5. Do the same for the taxonomy term you created in step 2: nothing happens, you have to enter the full path in the old (un)fashioned way.

Proposed resolution

Menu link autocomplete field should autocomplete paths for each content entity, not only nodes; if unfeasible, it should at least include taxonomy terms.

Remaining tasks

Discuss and fix.

User interface changes

None

API changes

TBD

Data model changes

TBD, hopefully none.

Release notes snippet

TBD

Comments

falcon03 created an issue. See original summary.

cilefen’s picture

Title: Menu Item autocomplete field only autocompletes node paths » Allow looking up more content entity types in menu item autocomplete
Version: 10.2.x-dev » 11.x-dev
Category: Bug report » Feature request
Priority: Major » Normal
falcon03’s picture

@cilefen I'm not sure I agree on considering this issue a feature request rather than a bug. Reading the help text "Start typing the title of a piece of content to select it. You can also enter an internal path "that is shown below the field it seems that its intended behavior would be to autocomplete paths for all "pieces of content" (and in deed taxonomy terms are content entities).

Anyway this is at least a major usability issue, considering the fact that we do not have any simple way in core to add taxonomy terms to menus (like the options available for nodes).

On a side note, the reason why after 10 or so years of work on entity field API and internal core architectures we still have to worry about implementations for each content entity is still a mistery for me, but that's another story :) Something I'd like to understand better now that I'm coming back to Drupal after several years

cilefen’s picture

Major bugs have no workaround. You described the workaround above.

Now that I’m thinking about this more, aren’t taxonomy term pages a view? Views are not content entities.

falcon03’s picture

@cilefen fair enough; we should discuss wether that workaround is acceptable for being in 2024 (and of course I'd say no), but I do not want to bikeshed on this: we'd better have this discussion in a policy issue.

Anyways I did not find anything on the fac that taxonomy term pages are now views; do you have the CR on hand? A quick Google search didn't help

cilefen’s picture

https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/taxon... but in fact it is optional. These are content entities otherwise.

pameeela’s picture

Title: Allow looking up more content entity types in menu item autocomplete » Provide support for altering which content entity types and bundles appear in menu link autocomplete
Related issues: +#3446857: Update menu link autocomplete to use allowed menu settings based on content type, +#3317769: Add support for linking to entities in CKEditor 5

This came up in context of including Canvas page entities in the autocomplete, which we will want to do. Something like what is proposed in #3317769: Add support for linking to entities in CKEditor 5 would be good I think, so that core can provide defaults but modules can opt their entities and bundles in where relevant?

damienmckenna’s picture

Now that #3317769 has been committed to core this can be worked on.

It might be worth providing a list of content entities in the text format configuration and letting site builders control which ones are allowed.

pameeela’s picture

I think it would be better to have this as global config somewhere since it doesn’t apply only to the text format. I’m not sure where but having settings in the text format that controls menu link settings just feels odd.

pameeela’s picture

I just realised that #3562968: Add autocomplete link field widget (similar to Linkit) is basically solving this, so we should probably close it as a duplicate? I’ll go through the related issues and try to consolidate.

pameeela’s picture

Yep I think it makes sense to focus this on #3562968: Add autocomplete link field widget (similar to Linkit) for now, we can figure out the UI piece later but that issue would at least add support for making this configurable in code.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.