Problem/Motivation
Steps to reproduce:
- Install Drupal (standard profile)
- Edit the "Content" view (/admin/structure/views/view/content)
- Add an exposed filter for the "Tags" (field_tags) field. Make sure to "Dropdown" as "Selection type".
- Change "Exposed form in block" to "Yes"
- Save the view
- Go the block layout page for the "Seven" theme (/admin/structure/block/list/seven)
- Click the "Place block" button next to "Content"
- Click "Place block" in the "Exposed form: content-page_1" row
- Restrict the visibility of the block by page: "/admin/content" (not necessary but to avoid confusion)
- Click the "Save block" button the block configuration modal
- Navigate to the "Content" page (/admin/content).
- You will see the exposed block with the "Tags" filter being empty.
- Add a new term "Test" in the "Tags" vocabulary (/admin/structure/taxonomy/manage/tags/add)
- Visit the content page again (/admin/content). The "Tags" filter is still empty.
Expected behavior: you can select "Test" in the "Tags" filter.
There is already another issue about terms in the exposed filter not updating @ #2900248: Exposed term filter is not updated when terms are added, deleted, or rearranged (caching issue?). That ticket is specific to the taxonomy term filter when the exposed filters are not displayed in a block. Applying the (working) patch in that issue will not resolve this issue.
Proposed resolution
The \Drupal\views\Plugin\BlockViewsExposedFilterBlock plugin inherits the cache contexts of the views display handler. This doesn't appear to be the case yet for cache tags.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3067937-13.PNG | 7.82 KB | kapilv |
| #13 | drupal-exposed_filter_block_cache_tags-3067937-13.patch | 705 bytes | askibinski |
Comments
Comment #2
rp7 commentedComment #3
rp7 commentedComment #4
rp7 commentedComment #5
rp7 commentedComment #6
wim leersWow, great catch! 👏
The steps to reproduce are wonderfully precise. Which should make it easy to turn this into a failing test! That'd make this much easier to fix in Drupal core :) Marking "Needs work" for that.
Comment #7
wim leersWouldn't solving this issue also solve #2900248: Exposed term filter is not updated when terms are added, deleted, or rearranged (caching issue?)?
Comment #9
undersound3 commentedI am experiencing this on a site using drupal 8.8.1.
Does anybody know of a workaround/patch?
Thanks
Comment #10
finex commented@undersound3: did you try patch #4?
Comment #13
askibinski commentedThere is an error in the patch in #4. Here is a new one. Still needs tests though.
Comment #14
kapilv commentedpatch applied cleanly. need review
Comment #15
porchlight commentedPatch worked for me in combination with the patch from the other issue mentioned in the description - https://www.drupal.org/project/drupal/issues/2900248#comment-13795169
Thanks!
Comment #16
catchPer #13 we need to add an automated test here to show the fix works.
Comment #22
mxr576I would consider this an outdated issue, I have tried to reproduce the issue by following the manual steps on 11.x today and I could not.
My gut says that this issue was resolved in #3493858: Extend ViewsBlockBase to merge cache metadata from display handler since the merge was merged fix is similar to #13.
Please re-open if you disagree.
Comment #23
xjmSaving credits according to our core issue credit guidelines. Thanks!