Problem/Motivation

When a Media reference field is configured to use the "Views" selection handler, the field widget description (help text) contains a broken UI element.
The MediaLibraryWidget currently appends the string "Allowed media types: @types" to the help text. While the "Default" selection handler provides a list of bundles for the @types placeholder, the "Views" selection handler does not return bundle constraints in the same way.

As a result, users see:

Type part of the media name. See the media list (opens a new window) to help locate media. Allowed media types:

The trailing colon with no types listed looks like a bug and creates a poor user experience.

Steps to reproduce

  1. Create a Media reference field on any content type.
  2. Set the "Reference method" to Views.
  3. Navigate to the node creation form.
  4. Observe the help text under the Media widget; it will show a trailing "Allowed media types:" label with no content following it.

Proposed resolution

Update MediaLibraryWidget to make the "Allowed media types" portion of the description conditional. Instead of always appending the string, the widget should check if any allowed types are actually present. If the list is empty (as is the case with the Views handler), the string "Allowed media types:" should be omitted, leaving the rest of the instructions intact.

User interface changes

  • Before: "...locate media. Allowed media types: " (Empty trailing label)
  • After: "...locate media." (Clean description when using Views handler)

Note: When using the Default handler, the behavior remains unchanged and will still list the allowed types.

Remaining tasks

None. Patch has been created.

Issue fork drupal-3626432

Command icon Show commands

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

vikramsaini1609 created an issue.