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
- Open a Page
- Start linkit
- Type in a known node id
"/node/<nid>" - Click OK
- Check inserted link
Proposed resolution
If only one result was found and this is matching the input, it should insert the internal link.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | node_link_with_anchor.gif | 2.46 MB | edwardsay |
| #3 | 3222939-linkit-select-first-automatically-3.patch | 15.44 KB | edwardsay |
Issue fork linkit-3222939
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
Comment #2
acrollet commentedI 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
Comment #3
edwardsay commentedThis 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.
Comment #4
dbielke1986 commentedOh, 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?
Comment #5
dbielke1986 commentedComment #6
edwardsay commented@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.
Comment #7
dschrier commentedThank 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?
Comment #10
mark_fullmerThe 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.
Comment #11
dschrier commentedI've tested this update on a couple of sites, and it works as described.
Comment #13
mark_fullmerComment #14
zoeblair commentedHey, 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?
Comment #15
mark_fullmerThis 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?
Comment #16
zoeblair commentedBug report here:
https://www.drupal.org/project/linkit/issues/3447669
Comment #18
mark_fullmerThanks 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.