MultiFilter for checkbox and palette fields

Created on 23 January 2024, over 1 year ago

Problem/Motivation

The filter for Metadata: Selection list has the option to Allow multiple selections, but enabling it breaks the filter for me.

Multi-select here would be great, especially if it plays nice with better_exposed_filters. :)

Steps to reproduce

  1. Add filter for Metadata: Selection list to the Asset Library view /admin/structure/views/view/acquia_dam_asset_library
  2. Check Allow multiple selections.
  3. Select OR for Type of operation expected. (I get the same behavior if I use the AND type of operation.)
  4. Add media via the asset library.
  5. Select 1 value from the filter and Apply.
  6. Get results as expected.
  7. Select a different value (but only select one value).
  8. I get zero results, and I see that the first option I selected is highlight as well as the second option I highlighted. See dam-multi-select-filter1.mov
  9. Hit Clear filter, but nothing changes; I still get zero results. See dam-multi-select-filter2.mov
  10. Refresh the page and select 2 or more values at once (holding down CMD or SHIFT), then it just gives me zero results and no way to clear it.
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States capysara

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

Merge Requests

Comments & Activities

  • Issue created by @capysara
  • 🇺🇸United States capysara

    Support ticket opened with Acquia
    Case Number
    01071056

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Unable to generate test groups
  • 🇺🇸United States capysara

    I create a MR to fix the issue with the single value select list, but the multi value select list still doesn't reset correctly.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Unable to generate test groups
  • 🇺🇸United States capysara

    Updated the MR to address #10 from IS

    Refresh the page and select 2 or more values at once (holding down CMD or SHIFT), then it just gives me zero results and no way to clear it.

    Now selecting multiple values should respect the filter_operation in the views filter config.
    The Clear button still doesn't work correctly.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Composer require-dev failure
  • Pipeline finished with Failed
    over 1 year ago
    Total: 2617s
    #147522
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Composer require-dev failure
  • Pipeline finished with Failed
    over 1 year ago
    Total: 2436s
    #147574
  • First commit to issue fork.
  • Merge request !75#3416582 – Fix clear filter → (Open) created by rajeshreeputra
  • 🇮🇳India chandu7929 Pune

    @Rajeshreeputra - Requested some changes, please take a look.

  • 🇮🇳India rajeshreeputra Pune

    Updated as per review feedback, requesting review.

  • 🇮🇳India chandu7929 Pune

    Verified recent changes and it looks good to me. I would request another sets of eyes.

  • Pipeline finished with Success
    12 months ago
    Total: 1195s
    #292143
  • Pipeline finished with Success
    12 months ago
    Total: 1070s
    #292186
  • I encountered an issue when using the patch while switching between grid and table with selected filters because the JavaScript was attempting to access the form element with id="views-exposed-form-acquia-dam-asset-library-widget". However, in some cases, it seems the form didn’t exist on the page, which resulted in a JavaScript error when trying to manipulate the form’s elements.

    Error Message (with private information removed):
    An error occurred while attempting to process https://your-site-url/admin/content/media-dam-widget/asset_library_type?media_library_opener_id=media_library.opener.editor&media_library_allowed_types[0]=documents_asset&media_library_allowed_types[1]=image_asset&...&_wrapper_format=drupal_ajax: document.getElementById(...) is null.

    Root Cause:
    The JavaScript was trying to interact with a form that wasn't present on the page at the time of execution, causing a null reference error.

    Possible Solution:
    By adding an early return when the form is not found, the script avoids further execution and prevents errors:

    if (!form) {
      return;
    }

    This ensures that the script only proceeds if the form exists, avoiding the null reference issue. It worked for me, but you all might have more context on how to properly resolve it. I’m just sharing my input in case it helps.

    I’ve attached the .diff file for context and the image of the original issue (with private information removed).

  • Status changed to Needs review 16 days ago
  • 🇺🇸United States becw

    I've encountered both of these issues:

    • The "Metadata: Selection list" views filter doesn't work in combination with any other views filter (either the "Search" filter or another "Metadata: Selection list" filter)
    • The "Clear Filter" button provided in the Media Library UI doesn't clear filters aside from the default "Search" filter

    I'm also running into:

    • The "DAM Assets: Property value" sort does not appear to work (though perhaps I'm using an incorrect property path?)
    • The "Metadata: Selection list" views filter may be doing partial matching, e.g. the value "Abc" matches both "Abc" and "Abcdef"

    I'm attaching an example of a view that exhibits these issues. Here's what my exposed filters and sorts look like:

    I find that:

    • When I enter a search term and no other filters, I get the expected results
    • When I select a single value from my "Content Source" dropdown (a "Metadata: Selection list" filter) and no other search/filters, I get the expected results
    • When I enter a search term and select a value from my "Content Source" dropdown, I get results matching the search term but NOT filtered by the "Content Source" metadata value

    On top of that:

    • When I select "Image" from my "Asset Type" dropdown (a "Metadata: Selection list" filter) and no other search/filters, I get results for "Image" assets and also "Image, purchased" assets (which suggests this is a substring match??)
    • When I change the "Sort by" or "Sort order" dropdowns, the sort order does not change (regardless of any other filters applied)

    Neither of the changes proposed in the MRs on this issue resolve my problems -- MR 30 throws a php error, and MR 75 clears the additional exposed filters but can't handle the exposed sorts.

  • 🇮🇳India vipin.mittal18 Greater Noida

    This issue should now be fixed against the 1.1.x branch instead of 1.0.x, as it is actively maintained.

  • Pipeline finished with Canceled
    15 days ago
    #585126
  • Pipeline finished with Canceled
    15 days ago
    #585124
  • Pipeline finished with Success
    15 days ago
    #585128
  • 🇺🇸United States becw

    Thanks! I tested these latest changes and found that:

    • Fixed: "Search", and multiple "Metadata: Selection list" filters now work in combination with each other
    • Fixed: The "Clear Filter" button now clears the "Search" filter and the "Metadata: Selection list" filters
    • Not working: Selecting "Image" from one of our "Metadata: Selection list" filters still matches assets with the metadata value "Image" OR the metadata value "Image, purchased"
    • Not working: Sorting does not work
    • Not working: The "Clear Filter" button does not reset the exposed sort form elements -- and highlights them in red with the messages "The submitted value All in the Sort by element is not allowed." and "The submitted value All in the Order element is not allowed."
Production build 0.71.5 2024