Problem/Motivation

If you start linkit to search for an internal node, and you know exactly the ID, our users will type in "/node/<nid>".
If you now klick on OK and you are not selecting the search result, it will insert a link like <a href="/node/nid"...., even if this is an internal link which sould look like this: <a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="<uuid>" href="/node/<nid>"...

This leads to wrong links on multilingual sites because drupal is not rendering a prefix like /en/node/<nid> or /fr/node/<nid>. The inserted link will be treated like an external link.

Steps to reproduce

  1. Open a Page
  2. Start linkit
  3. Type in a known node id "/node/<nid>"
  4. Click OK
  5. Check inserted link

Proposed resolution

If only one result was found and this is matching the input, it should insert the internal link.

Issue fork linkit-3222939

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

dbielke1986 created an issue. See original summary.

acrollet’s picture

I can confirm this issue, it's also seen when clicking in the modal but not on the node title, and then pressing 'Save'. We resolved this for the va.gov CMS by adding a custom filter that populates the metadata for node links when missing:

https://github.com/department-of-veterans-affairs/va.gov-cms/pull/5929

edwardsay’s picture

This issue was reported as problematic for cases when you need to add an anchor to the node URL.

I created a patch to address this issue. The autocomplete menu item will be automatically selected on the autocomplete menu close if it's the only item available. This patch can be applied to Linkit module version 6.1.0

Attached is a .gif with the demonstration of how the link to Node with anchor will work after applying the patch.

dbielke1986’s picture

Oh, yes! Great, because we are currently activating the CKEditor Anchor Link and are also using exactly this functionality.

It would be nice if this fix would be included in an official release.

@edwardsay:
Are you using the alpha2 of the AnchorLink module in CKEditor5 and what are your experiences with it so far?

dbielke1986’s picture

Version: 6.0.0-beta2 » 6.1.x-dev
edwardsay’s picture

@dbielke1986 Yes, we use Anchor Link 3.0.0-alpha2 and it works well.

However, this particular issue is unrelated to the Anchor Link CKEditor plugin. This is solely related to the Linkit plugin.

dschrier’s picture

Thank you for creating this patch! Unfortunately, it does not appear to apply to 6.1-dev, or 6.1.2. Specifically, it looks like there is a problem with the compiled JS file. If you have a chance, could you take a look?

mark_fullmer made their first commit to this issue’s fork.

mark_fullmer’s picture

Title: Linkit is creating external links if you do not select the search result » Do not require selection of autocomplete if only one match (pressing 'Submit' is sufficient)
Category: Bug report » Feature request
Status: Active » Needs review

The merge request should provide a version that applies cleanly to 6.1.x. I've also re-characterized this issue as a feature request, rather than a bug, since I see the assumption that the single matching result should be the one the user want to be a convenience, rather than an expectation.

dschrier’s picture

Status: Needs review » Reviewed & tested by the community

I've tested this update on a couple of sites, and it works as described.

  • mark_fullmer committed fc15a679 on 6.1.x
    Issue #3222939 by mark_fullmer, edwardsay, dbielke1986: Do not require...
mark_fullmer’s picture

Status: Reviewed & tested by the community » Fixed
zoeblair’s picture

Hey, this is a problem for my site where we have ckeditor anchor_link installed. My client is trying to paste a URL in, but the only match is a suggestion for an anchor which they can't ignore anymore, so it's switching their entire external link to an anchor instead.

How can they ignore the only suggestion if they want to use exactly what they pasted?

mark_fullmer’s picture

How can they ignore the only suggestion if they want to use exactly what they pasted?

This is a great question/point, and should be addressed. I'm not sure if it means that we should just revert this change, as the assumption about being able to use a single matching suggestion may be incorrect. Do you mind creating a new issue -- tagged as a bug report -- to look into the proper resolution?

zoeblair’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mark_fullmer’s picture

Thanks for the bug report. Based on what is described in #3447669: No longer a way to post a link as-is if there is 1 pattern match, I am concluding that this feature request was not a good idea to start with, since users don't always want to accept a suggestion provided by Linkit, even if there is only one suggestion. I'll work to back out the change in the 6.1.x and 7.x branches.