Problem/Motivation
I know there were issues previously reported that are related to this, but I'm still experiencing an issue where contextual filters aren't being respected for media type in the media library widget modal with "Show all files in Root directory" setting checked on. This is specific to fields that reference media and use Media Library widget in form display. When adding media to a node through that field, the modal pops up, you can see the tabs showing each available media type, but all existing media displays no matter which tab is selected. I would expect the media to be filtered depending on the selected tab.
Steps to reproduce
- Enable Media
- Enable Media Library
- Require latest, stable Media Directories via composer (2.0.1) with jsTree library
- Enable Media Directories + dependent modules
- Add new field to content type (basic page or article) that references Media (chose Image, Remote Video, Document)
- Make sure Media Library widget is selected for the field's form display
- Check "Show all files in Root directory" at Media directories settings: /admin/config/media/media_directories
- Upload a few new media items: image, video, and file
- Create or edit content type with new Media reference field, Add media to get the modal with the tabs.
- Notice all media types display no matter what tab is selected, there's no contextual filtering.
- Unchecking "Show all files in Root directory" at Media directories settings: /admin/config/media/media_directories will respect the contextual filters
Proposed resolution
- Possibly update the group id in the query in the MediaDirectory view filter? Similar to solution from related issue with MediaDirectoryArgument
Comment | File | Size | Author |
---|---|---|---|
#4 | 3186374-use_new_query_groups-4.patch | 4.58 KB | ytsurk |
Screen Shot 2020-12-03 at 2.04.04 PM.png | 129.93 KB | brittany.huntzberry |
Comments
Comment #2
ytsurkThank you for reporting this issue, with a super clear summary. I'll have a deeper look soonish.
This means, we're breaking the media libraries Add-Form, which shall be considered as critical bug.
Comment #3
ytsurkWe need to create a new query group instead of re-using the existing group 0.
Comment #4
ytsurkExpanded to all "queries" and adjusted the jsTree Root label, if "show all files in root directory" is set.
Comment #5
brittany.huntzberryThank you so much for creating a patch so quickly! I've applied patch #4 locally without any issues.
I checked the media library widget modal and the contextual filter is now respected with the setting checked on. I also did a check without the setting on and it also works as designed. I didn't notice any major regressions either, thanks again!
Comment #7
ytsurkThank you for reviewing :D