Fixed
Project:
Linkit
Version:
7.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
16 Jul 2021 at 07:03 UTC
Updated:
17 Sep 2026 at 19:49 UTC
Jump to comment: Most recent, Most recent file
When searching on e.g. a node path or the frontpage (/), query parameters and fragments are stripped from the URL in the suggested paths.
When the user is entering an URL with query parameters or fragments, add them to the suggested path.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | before-click-on-suggestion.png | 42.75 KB | rajeshreeputra |
| #11 | Screenshot 2021-10-22 at 09.02.13.png | 62.24 KB | jeroent |
| #11 | Screenshot 2021-10-22 at 09.02.22.png | 50.4 KB | jeroent |
| #7 | 3223919-7.patch | 7.15 KB | jeroent |
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
jeroentComment #3
jeroentComment #4
jeroentComment #6
jeroentComment #7
jeroentRemoved 2 unused use statements.
Comment #9
jeroentComment #10
idebr commentedWasn't this fixed in #2895153: Linkit filter should honour the URL query and fragment?
The issue title mentions query parameters are stripped from the input URL, but the issue summary mentions the query parameters are stripped from the suggestion paths. What exactly is being fixed here?
Comment #11
jeroentUpdated the IS. I hope it makes more sense now.
The problem is that when you enter a path with a query parameter e.g. /node/1?test=1, the EntityMatcher will recognise this path as a node path and a suggestion is shown:

When you click on the suggestion the entered query parameters and fragments are removed:

The patch in #7 makes sure that the query parameters and fragment are preserved, when clicking on the suggestion.
This issue was a follow-up of #2712951: Linkit for Link field but it seems the same behaviour occurs when using the dialog in a CKEditor field.
Comment #12
stefan.atanasov commentedHey,
I can confirm that preserving query parameters was reported as expected behaviour from a client and applying this patch solves it.
Details:
Please do let me know if you need more details regarding the case and I'll try to comeback to you asap.
Cheers!
Stefan
Comment #13
rajeshreeputraI can confirm linkit is not removing the query parameter from the field even after clicking on the suggestion.
Details:
Comment #14
jeroentMoving to rtbc, since 2 separate people mentioned the patch is working.
Comment #15
bogdan.dinu commentedI don't think the proposed solution is ok because it is saving the query and fragment in the uri. That is not compatible with the core link schema or other modules that use the core link schema.
I propose saving the query and fragment in the options base field of the link field as described in the core link schema.
My solution only works with the patch from this issue on linkit_field https://www.drupal.org/project/linkit_field/issues/3349013
because the linkit widget from linkit doesn't use the node path/alias.
Comment #16
bogdan.dinu commentedThe previous patch is incomplete. I appologize!
I uploaded a new one (it is based on the patch from #7).
Comment #17
mark_fullmerJust a note that recently #2712951: Linkit for Link field was merged into the 6.0.x branch, so a patch that addresses this for the link field context can build on that foundation.
Comment #18
mark_fullmerNote that the equivalent issue reported on the 6.x branches for this module has been fixed in #3359375: Query fragments or anchors on internal URLs in link fields get lost on re-editing.
As is practicable, sites should update to 6.x rather than continuing to use 8.x-5.x
Comment #19
mark_fullmerUpdate: upon revisiting this now, my analysis in #18 is incorrect. *This* issue describes a different request than was dealt with in #3359375: Query fragments or anchors on internal URLs in link fields get lost on re-editing. Setting this to track the current development branch for Linkit.
Comment #21
mark_fullmerI've added an MR that is based on the patch from #16 that applies to the 7.x branch. Setting back to needs review based on the change between #14 and #16.
Comment #22
mark_fullmerThis introduces test failures, per https://git.drupalcode.org/project/linkit/-/jobs/5001403 . Setting back to "Needs work."
Comment #24
rhezios commentedSnapshot of latest state of MR for usage with composer patches
Comment #25
mark_fullmerComment #27
timohuismanI've updated the MR with the latest changes from 7.x. The test failures from #22 are resolved. Attached is a snapshot of the current state of the MR, so it can be safely used with composer-patches.
I've used Claude Code to debug the CI failures.
Comment #28
idebr commented\Drupal\linkit\Plugin\Linkit\Matcher\FrontPageMatcher::getQueryAndFragment can be replaced with \Drupal\linkit\Utility\LinkitHelper::getQueryAndFragment now that #2712951: Linkit for Link field is committed
Comment #29
timohuisman#28 is addressed in the MR, thanks.
Comment #30
idebr commentedLooks good to me! I'll mark this RTBC so @mark_fullmer has the chance to take a second look before commit
Comment #31
mark_fullmerComment #32
mark_fullmerThis all looks good to me. Thanks everyone for the work, and especially @timohuisman for updating the MR and @idebr for the review!