Exacte same issue as #2755403: Edit link don't remove data- attributes which seems to be reintroduced. Copy from the steps to reproduce from the original ticket:
When editing a link, the data- attributes will in some situations be kept in the old state.
Steps to reproduce:
Add an internal link to an entity (entity:node/1)
The data- attributes will be set
Edit that link, and set an external URL as href.
The data- attributes is the same as before.
This causes the linkit_filter to always override the href.
Expected behavior:
Add an internal link to an entity (entity:node/1)
The data- attributes will be set
Edit that link, and set an external URL as href.
The data- attributes removed.
Original commit that fixed this, which seems gone in current release and dev version: https://git.drupalcode.org/project/linkit/commit/cc3edc5
Attached is a patch that fixes it again.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | linkit_rename-stale-data-attributes_3111578.patch | 558 bytes | vastr |
| #3 | linkit_rename-stale-data-attributes_3111578-3.patch | 668 bytes | briantschu |
| #2 | linkit_remove-stale-data-attributes-3111578-2.patch | 520 bytes | rang501 |
| linkit_remove-stale-data-attributes.patch | 701 bytes | weseze |
Comments
Comment #2
rang501 commentedThis patch doesn't fix it, at least not my use case - adding link around entity embed elements will preserve data-* attributes if the link is external.
The logic inside the form submit handler seems weird - if the attribute value is empty then it tries to check if $link_element is empty, but it doesn't make sense because it is usually an array so this is most likely true. I'm assuming this is wrong and it should check attribute value inside of $link_element.
Comment #3
briantschuBuilding on this, let's set the `$form_state` values to match what is in `$link_element` so the `data-*` attributes update.
Comment #5
liam morlandIs there a reason it needs to use data attributes? Why not look at the
hrefattribute. If it is an internal link likeentity:node/1, convert it to the correct path for output. Otherwise, leave it unchanged.Doing it this way would probably also fix #3222939: Do not require selection of autocomplete if only one match (pressing 'Submit' is sufficient).
Comment #6
mark_fullmerI believe this was resolved in #3443845: When [Enter] key is used to replace a link, the previous link's attributes are not removed. Marking as "Postponed (maintainer needs more info)" in case there is still a different issue here. If there is, updated steps to reproduce would be great. Thanks!
Comment #7
mark_fullmerComment #8
mark_fullmerComment #9
vastr commentedPatch for the 7.0.2.
Comment #10
weseze commentedRetested this in version 7.0.9 and the patch is longer needed. Marking as fixed.