Problem/Motivation

Update: This appears to be an issue with Select List even if you don't use the multi-value. The clear button doesn't work because it should be setting the value to "All" not empty.
Original report:
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.

Issue fork acquia_dam-3416582

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

capysara created an issue. See original summary.

capysara’s picture

Title: MultiFilter for checkbox and palette fields » Multiple values for select list filter breaks the filter
capysara’s picture

Support ticket opened with Acquia
Case Number
01081685

capysara’s picture

Title: Multiple values for select list filter breaks the filter » Metadata: Selection list filter breaks the filter in the Asset Library
Issue summary: View changes

capysara’s picture

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

capysara’s picture

Issue summary: View changes
capysara’s picture

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.

rajeshreeputra made their first commit to this issue’s fork.

chandu7929’s picture

Status: Active » Needs work

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

rajeshreeputra’s picture

Status: Needs work » Needs review

Updated as per review feedback, requesting review.

chandu7929’s picture

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

ricardo garcía’s picture

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).

becw’s picture

StatusFileSize
new10.51 KB
new55.39 KB

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:

 Search, Content Source, Asset Type, Sort by, Order.

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.

vipin.mittal18’s picture

Version: 1.0.x-dev » 1.1.x-dev
Status: Needs review » Needs work

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

becw’s picture

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."
becw’s picture

I have also found that filter values containing an ampersand are not handled correctly. Specifically, one of our DAM select lists contains values like "Places | Classroom & Education". When this is selected as a filter, I get an error on the filter select list, no results, and the error message "The submitted value Places | Classroom in the image_classification element is not allowed."

chandu7929 changed the visibility of the branch 3416582-multiple-values-for to hidden.

chandu7929’s picture

Status: Needs work » Needs review

Validated changed of MR197 and can confirm following items have been fixed:

  1. Fixed: "Search", and multiple "Metadata: Selection list" filters now work in combination with each other
  2. Fixed: The "Clear Filter" button now clears the "Search" filter and the "Metadata: Selection list" filters
  3. Fixed: Selecting "Image" from one of our "Metadata: Selection list" filters still matches assets with the metadata value "Image" OR the metadata value "Image, purchased"
  4. Fixed: Sorting does not work
  5. Fixed: 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."

Hence requesting review.

chandu7929 changed the visibility of the branch 3416582-fix-clear-filter to hidden.

chandu7929’s picture

Hello @becw,

With respect to your issue:

I have also found that filter values containing an ampersand are not handled correctly. Specifically, one of our DAM select lists contains values like "Places | Classroom & Education". When this is selected as a filter, I get an error on the filter select list, no results, and the error message "The submitted value Places | Classroom in the image_classification element is not allowed."

This is also fixed.

rajeshreeputra’s picture

Status: Needs review » Reviewed & tested by the community

Validated changes in MR!197 and it fixes the items listed in #21.

vipin.mittal18’s picture

StatusFileSize
new69.45 KB

I have validated all the issues raised in this ticket, and everything is working fine.
Filters used are mentioned in the screenmshot
filter

becw’s picture

The latest work in MR!197 is working great for me!

  • Fixed: "Search", and multiple "Metadata: Selection list" filters now work in combination with each other
  • Fixed: The "Clear Filter" button now resets all of the exposed form elements, including the sort and sort direction select lists
  • Fixed: Sorting now works
  • Not working: Using the "Metadata: Selection list" filter with values that contain ampersands

I've attached screenshots of the remaining issue, but if you'd prefer I could open a separate ticket.

chandu7929’s picture

StatusFileSize
new428.41 KB

Hello @becw,

I have verified with "Metadata: Selection list" with field "Usage right" and don't see any issue even if I have asset tagged with label that contains ampersands, please see the below screenshot.
Filter
Also, could you please let us know how you are creating filter "Image Classification" and which filed being used for this filter?

japerry made their first commit to this issue’s fork.

japerry’s picture

Status: Reviewed & tested by the community » Needs work

Multiple test failures, so moving to NW

rajeshreeputra’s picture

Status: Needs work » Needs review

Fixed failing test, requesting review.

japerry’s picture

Status: Needs review » Fixed

Tests and code looks good. Merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.