Add a filter field to the token browser

Created on 3 October 2024, 9 months ago

Problem/Motivation

At the moment you have to expand every token in the token browser, some top level items are two or three additional levels deep, to get an overview of the list of available tokens or find some you are looking for in case you are already familiar with the concept of tokens.

* I've reviewed and discussed the ui of the token module from an a11y perspective together with @drupa11y - this issue is one of the results.

Steps to reproduce

Try to find the Fallback date format for a comment an author has posted

Proposed resolution

Add a filter field on top of the token table within the token browser. filtering narrows down the list of available tokens in the table to the ones that match the filter criteria. That way it isn't required for someone neither memorizing all the token names nor at least the rough position of a desired token in the hierarchy. The user is able to filter for the terminology they are familiar with. In case that brings no match the person is still able to expand the different token and search for the token they are looking for.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

User interface

Created by

🇩🇪Germany rkoller Nürnberg, Germany

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rkoller
  • 🇩🇪Germany rkoller Nürnberg, Germany
  • 🇦🇺Australia kim.pepper 🏄‍♂️🇦🇺Sydney, Australia
  • 🇮🇳India dev.drupal.ln

    Hi @rkoller

    I have created a patch to address the issue mentioned above. This patch enhances the browse token functionality by providing a filter option, allowing users to easily filter and locate specific tokens. Additionally, I am attaching a screenshot for reference. Please review once.

    Thank you.

  • Assigned to batigolix
  • Status changed to Needs review 2 months ago
  • 🇳🇱Netherlands batigolix Utrecht
  • Merge request !93Add patch → (Open) created by batigolix
  • Pipeline finished with Success
    2 months ago
    Total: 244s
    #476778
  • 🇳🇱Netherlands batigolix Utrecht

    I moved the patch to a merge request.

    I tested this change:

    - If you click on a token in the list, it will populate the last field that had focus. With this change, the last field will become the new token filter field. See screenshot
    - It needs some styling to make it look a bit smoother (I checked it with Gin) . See screenshot
    - I checked how filter field are being used in Views , maybe that pattern can be applied here as well. See screenshot

  • 🇳🇱Netherlands batigolix Utrecht
  • 🇩🇪Germany rkoller Nürnberg, Germany

    Thank you @dev.drupal.ln & @batigolix for picking up and working on the issue, and apologies for the late reply, i am quite behind on going through all the a11y issues across issue queues that received attention recently. :( Todays a11y meeting was a timely and necessary reminder. So I went ahead and have taken a look at MR93 - a few observations:

    1) The styling of the filter field needs some work - in general for Claro the design should orient to the Drupal Design System, for Gin I am not aware of any Figma file. Problem with the current state of the MR, the border has a color contrast of 1.2:1 rgb(235, 235, 235)/rgb(255, 255, 255) in Claro and Gin which is not in line with WCAG 2.2 SC1.4.11.
    claro

    gin

    For Claro the border color should be var(--input-border-color) and on hover var(--input--hover-border-color), the border should be solid and the size var(--input-border-size). The filter field in Claro has a height of 48px (the min-height property for that is calc(((var(--input-padding-vertical) + var(--input-border-size)) * 2) + var(--input-line-height))).
    For Gin the border color should be var(--gin-border-color-form-element) and on hover var(--gin-color-text) (checked the filter field on admin/content for the variable on hover), the border should be solid, the size is 1px, and the corners should be rounded.
    The filter field in Gin has a height of 40px (the min-height property has calc(var(--input-padding-vertical) * 2 + var(--input-line-height)). There might be more styling details for Claro and Gin to mind, the variables provided for Gin are only for the light mode, they might vary for the dark mode.

    2) The input field is missing a label (WCAG 2.2 SC 3.3.2)

    3) The filter field is missing an outline when being in focus (WCAG 2.2. SC 2.4.7 & SC 1.4.11)

    4) If you are entering a term to filter for into the filter field the list underneath is immediately updated accordingly. This would happen to non-sighted users unexpectedly, which is not in line with WCAG 2.2. 3.2.2. In project browser ( 🐛 Improve the accessibility of the search field Active ) we’ve applied the following approach, we’ve added a search button (for the token module the button could be labeled Filter analogous), and the user can either press enter within the filter field or tab to the filter button and then filter. That way the user is in control.

    5) If a user wants to clear the input of the filter field they have to use the back space button. If someone assumes pressing the ESC key would clear the field that closes the token dialog instead. It might be worth to consider to again apply the same approach that is used for project browser and currently proposed for the field ui Add a clear button to the fields ui Active , that way the behavior would become consistent across Core.

    6)

    If you click on a token in the list, it will populate the last field that had focus. With this change, the last field will become the new token filter field.

    this behavior is problematic. That way a keyboard user has no way to accomplish their key task, inserting a token into a field in the background of the token dialog.

    7) the hierarchical list becomes hard to read after you have filtered for a string. the treetable is already hard to comprehend in the unfiltered form, but if you enter something into the filter field (for example user), you dont have a top level element as the first element but one that is from the second or third level (the exact level is impossible to assess)

    8) Looking at the treeTable problem, that reminds me to the more fundamental question, about how to proceed - there is 📌 Token UI 2.0 Active about Token UI 2.0. It is the question what would be the best approach for the Token UI going forward.

    • Should there be a fundamentally different UI and all other issues postponed until a consensus is reached on Token UI 2.0?
    • Should there be a fundamentally different UI but until a consensus is reached there should be smaller issues like this one improving the status quo.
    • Or should we proceed in the current direction and iterate in small steps with issues like this?

    Uncertain what the best approach might be. In regard of the ideation for Token UI 2.0, I’ve suggested in today’s a11y meeting to raise the topic in one of the future weekly UX meeting on friday.

Production build 0.71.5 2024