Add a configuration setting to use the field's help text

Created on 9 February 2024, over 1 year ago

Problem/Motivation

Our UX designers have recommendations for links that are specific to our site. They want those recommendations to show between the Link field label and the field itself. The problem is the that the link help text is hard-coded in the module in this file: linkit/src/Plugin/Field/FieldWidget/LinkitWidget.php to read: "Start typing to find content or paste a URL and click on the suggestion below."

Proposed resolution

One solution would be to use the field help text if it exists and to use the hardcoded text as a fall-back.

✨ Feature request
Status

Active

Version

6.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States skyriter

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

Merge Requests

Comments & Activities

  • Issue created by @skyriter
  • πŸ‡ΊπŸ‡ΈUnited States skyriter
  • πŸ‡ΊπŸ‡ΈUnited States skyriter
  • Merge request !38Concatenate the field help text β†’ (Open) created by skyriter
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    82 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States skyriter

    After discussion with other developers on the project, I opted to not completely replace the help text but to concatenate it, both to have consistency with the help test across all Linkit widgets and to minimally affect existing fields.

  • πŸ‡ΊπŸ‡ΈUnited States davidmpickett

    This seems like a good compromise. An additional enhancement to communicate this novel behavior to Site Builders might be to add some explanatory text to the Widget settings. Maybe something like:

    Help text for URL field
    The following default help text will be displayed for the URL field. "Start typing to find content or paste a URL and click on the suggestion below."
    If you add your own help text in the field settings, it will display after the default help text.

    This could be inserted between the Placeholder for URL and Placeholder for link text.

  • πŸ‡©πŸ‡ͺGermany mrshowerman Munich

    Let me add another aspect to the discussion:
    I wonder why Linkit's widget uses a fixed help text for all cases, in contrast to Core's LinkWidget, which has 3 different help texts, depending on the link type setting (internal links only, external links only, internal and external links allowed).

    "Start typing to find content" doesn't really make sense when only external links are allowed; same goes for "paste a URL" with internal links only.

    Not sure if this is the right place for that addition, or we should create a separate issue.

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson
  • πŸ‡ΊπŸ‡ΈUnited States alison

    After discussion with other developers on the project, I opted to not completely replace the default help text but to concatenate it field's help text to it, both to have consistency with the help text across all Linkit widgets on a given site and to minimally affect existing fields.

    I think this ⬆️ is a good plan, also because it's how help text works on fields that use the core LinkWidget. On my fields that use the core LinkWidget, the resulting help text is actually an unordered list -- perhaps, for UX consistency (and the simplicity of just, using an established pattern from Drupal Core), we could do that with Linkit-enabled link fields?
    πŸ‘‰ Here's how core + user-provided help text is put together for the core LinkWidget: https://git.drupalcode.org/project/drupal/-/blob/b57dbb43806a5434c7f7400...

    And here's an example of the resulting help text markup (from one of my link fields that uses core LinkWidget) -- the first list item is my custom help text, the second list item is provided by Core:

    <div id="edit-field-card-slider-slides-0-inline-entity-form-field-slide-link-0-uri--description" class="form-item__description">
      <div class="item-list">
        <ul>
          <li>If filled in, the <em>slide title</em> will be a clickable link.</li>
          <li>Start typing the title of a piece of content to select it. You can also enter an internal path such as <em class="placeholder">/node/add</em> or an external URL such as <em class="placeholder">https://example.com</em>. Enter <em class="placeholder">&lt;front&gt;</em> to link to the front page. Enter <em class="placeholder">&lt;nolink&gt;</em> to display link text only. Enter <em class="placeholder">&lt;button&gt;</em> to display keyboard-accessible link text only.</li>
        </ul>
      </div>
    </div>
    

    Re: #7 -- makes sense. I suppose it's out of scope for this issue, but I don't feel strongly about forcing a new issue, except that there's always a chance the added scope makes the resolution take longer -- but, I don't feel strongly about it.
    πŸ‘‰ For reference, here's where that description text is set in core.

Production build 0.71.5 2024