Problem/motivation

Code changes in #3538856: Field widget broken if there's multiple link fields, one without link text enabled failed to scope when to apply the "Automatically populate link text from entity label" configuration option properly by removing code that looked for data-linkit-widget-title-autofill-enabled.

As a result, all Link fields on sites using 7.0.8 or later receive the automatic population behavior regardless of configuration.

Steps to reproduce

  1. Create a link field with the Linkit widget, configured with "Automatically populate link text from entity label" set to "No"
  2. Populate the URL using autocomplete.
  3. Observe that the link title is autopopulated despite the configuration setting

Proposed resolution

diff --git a/js/linkit.autocomplete.js b/js/linkit.autocomplete.js
index e790077..9fd28cc 100644
--- a/js/linkit.autocomplete.js
+++ b/js/linkit.autocomplete.js
@@ -76,7 +76,7 @@
       const linkSelector = event.target.getAttribute('data-drupal-selector');
       if (linkSelector && linkSelector.endsWith('-uri')) {
         const titleSelector = linkSelector.slice(0, -4) + '-title';
-        const $linkTitle = $(`[data-drupal-selector="${titleSelector}"]`, $context);
+        const $linkTitle = $(`[data-linkit-widget-title-autofill-enabled][data-drupal-selector="${titleSelector}"]`, $context);
         // Don't overwrite an existing label unless we already replaced it
         // before.
         if ($linkTitle.length > 0 && (!$linkTitle.val() || $linkTitle.hasClass('link-widget-title--auto'))) {
This module uses Gitlab CI for automated testing of proposed code changes. To contribute code changes, create a merge request. Patch files will not trigger automated testing and are not sufficient for review.

Comments

mark_fullmer created an issue. See original summary.

  • mark_fullmer committed 54e757bb on 7.x
    Regression: Link field title autocomplete setting not respected (#...
mark_fullmer’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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