Javascript live-filter functionality for widget results (for large taxonomies)

Created on 9 April 2022, over 2 years ago
Updated 19 December 2023, 11 months ago

Drupal 7 issue: #2007164: Add filtering for large taxonomy trees

Problem/Motivation

When working with large taxonomies, it would be very helpful to have an optional search input field above the tree widget to reduce the number of results displayed.

This should be solved using JavaScript by live string comparison, and the non-matching items should simply be hidden as long as the search term is present.

Steps to reproduce

Proposed resolution

Add a setting to enable this functionality per field instance widget
Allow selecting the filter strategy: Contains, Starts with
Show an input field above the widget
When entering a string into the input field, live filter the displayed terms by hiding non-matching

Remaining tasks

Discuss
Implement
Test
Release

User interface changes

API changes

Data model changes

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany Anybody Porta Westfalica

    Just ran into this again and still this would be super helpful.

  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany maacl

    I also needed this for a project, and created a basic version based on the D7 patch. Still needs some work, but might be worth a quick review about the approach.

  • Status changed to Needs work over 1 year ago
  • First commit to issue fork.
  • Status changed to Needs review 11 months ago
  • 🇩🇪Germany marcoliver Neuss, NRW, Germany

    I've pushed some updates to the issue fork:

    • switched to using the once() method provided by core
    • added the search attribute to the config schema
    • some general cleanup
    • added a further option to preserve the children of matched terms

    The last point is a requirement that has cropped up in a project we're currently working on. Basically you have a tree where for example the first level is cities and the second level is zip codes associated with these cities. Previously if you were to search for a city name, the zip codes would disappear. If you set the new config value to TRUE, the (non-matching) children of matching terms will also remain visible.

Production build 0.71.5 2024