Preserve query parameters and fragments when directly inputting a path.

Created on 20 March 2023, over 1 year ago
Updated 21 March 2023, over 1 year ago

Problem/Motivation

Linkit Widget for link fields is not preserving the query and fragment (anchor) of the input url.
There is a similar issue raised on the linkit issue board ( https://www.drupal.org/project/linkit/issues/3223919 Preserve query parameters and fragments when directly inputting a path. RTBC ) for which I submitted a patch to make it work with the current one.
The initial solution proposed on that issue is adding the query and fragment in the uri, which I consider is not a correct way to do it because it is not using the code link schema and it breaks compatibility with the core link widget or other plugins that support the core link schema.
The core link schema includes an options map that is used to store the query and the fragment.

Steps to reproduce

- enable the linkit field widget for a link field
- paste an internal url that includes query and fragment
- save the entity
- the generated link for that field is missing the query and fragment parts

Proposed resolution

- add separate hidden fields for query and fragment in the LinkitWidget that are updated by the autocomplete suggestions js (part of the patch in the issue I posted on the linkit issue board)
- save the fields in the options base field of the link field
- make the distinction between the uri that is saved in the database (which should have the query and fragment) and the uri_as_url which is shown in the input field and should show the query and fragment) <-- this is the reason I didn't submit the patch on the LinkitWidget from the linkit module

Remaining tasks

- integrate the changes in the LinkitWidget in the linkit module

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇷🇴Romania bogdan.dinu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024