Problem/Motivation
The original issue is here but for the Drupal7 Views module. Below is copy/paste from that issue. All credits to @uq
Currently when a view uses AJAX pager and exposed filter with a default value at the same time, the view is not providing an accurate result when navigating the page.
The issue here was within the javascript of views. If the parameter doesn't have a property or if it is null (in this case, the date value is null after you selected "-Year"), it removes the parameter in the request. If the parameter is removed, Views will set the filter to the default value.
Hope this helps!
Steps to reproduce
To reproduce the issue:
1) Create a content type with a date field
2) Create a number of nodes with above content type
3) Create a View using unformatted list and fields under Format
4) Add Content: [Your date field] under Filter Criteria
5) Select Year under Filter Granularity
6) Check the checkbox "Expose this filter to visitors, allow them to change it" in the Configure filter criterion popup
6) Select a year (e.g. 2014) under Operator
7) Click Apply (all displays)
8) Click Advanced > User AJAX and select Yes
9) Save the view and go to the view page
10) Select "-Year" in the exposed filter and click apply
At this point, you should see a list of nodes with that field and a pager underneath
11) Go to page 2 through the pager
The list of nodes are gone and the exposed filter is reset to the default value.
Proposed resolution
The patch allows empty property to be passed within the query string parameter.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | interdiff-29-31.txt | 779 bytes | ilya.no |
| #31 | 3100826-31.patch | 8.21 KB | ilya.no |
| #20 | interdiff-19_20.txt | 490 bytes | gauravvvv |
| #20 | 3100826-20.patch | 818 bytes | gauravvvv |
| #16 | 3100826-16.patch | 1.57 KB | _utsavsharma |
Comments
Comment #2
nikita_ttComment #4
mwilburI ran into a similar problem that patch #2 provided helped with. This issue seems to be present for exposed combined fields filters with no value when applied to a view as well.
Steps I took to reproduce the same issue:
The list of results should disappear. I encountered this bug across a couple of different Drupal 9 sites, so I rerolled the patch for 9.3.x
Comment #5
damienmckennaSimplifying the tags a little.
Comment #7
mwilburUpdating formatting to pass the code quality checks.
Comment #8
ranjith_kumar_k_u commentedComment #9
ranjith_kumar_k_u commentedComment #10
gauravvvv commentedfixed linting issues in patch, Rerolled patch #9, Attached interdiff for same. please review.
Comment #13
damienmckennaComment #15
michelleI re-rolled #10 to work on 9.5.1. The only difference seems to be a blank line? Not sure why that made it not apply but this one does.
Comment #16
_utsavsharma commentedFixed CCF for 9.5.x in #16.
Comment #17
_utsavsharma commentedComment #19
ilya.no commentedAttaching patch for the latest version. I haven't succeeded with tests so far, will get back to them later.
Comment #20
gauravvvv commentedI have fixed the CC failure, attached interdiff for same. please review
Comment #22
ilya.no commentedThanks for the proper update. I've added fix for tests.
Comment #23
smustgrave commentedBelieve this still needs a test for the exact problem.
Updating the failing test I don't believe covers the change. &title= is not a default value that I can tell and actually probably shouldn't be in the URL I think if no value is present.
Comment #24
gauravvvv commentedComment #25
ilya.no commentedAttaching patch with new test case.
About
&title=part, I've tested following case - I updated 'test_content_ajax' view and switched off AJAX option and checked URLs and this part was presented. So, I assume this as normal behaviour, as non-AJAX view has the same URL.Comment #26
ilya.no commentedSorry for the a bit wrong patch. Attaching proper one.
Comment #29
ilya.no commentedAttaching patch with the fix for tests.
Comment #31
ilya.no commentedFixing wrong function call.
Comment #32
smustgrave commentedBelieve this is ready! Thanks for adding that additional test!
Comment #33
quietone commentedI'm triaging RTBC issues. I re-read the IS and the comments. I didn't find any unanswered questions. But there is not a failing test to prove the change works.
Reading the patch I have questions about the tests.
This is changing the source for the current tests for node 7 -> 11. Does this mean we are losing test coverage?
Why is this needed?
So the new test is largely a duplicate of the existing one. And it looks like some refactoring could make the differences between the two tests easier to see. But that is probably out of scope. Plus, it is better to fix the bug and have a followup than to hold this up. What would help is a comment in the setup to explain the need for the later nodes to be different.
However, I am not setting this to Needs works. I will leave at RTBC and let another committer make the decision because I don't work with FuncationalJavascript tests.
Comment #36
lauriii#33.1 I don't think we've lost test coverage, the existing tests have been updated.
#33.2 Fixed on commit.
Committed d251a98 and pushed to 11.x. Also backported to 10.1.x as a non-disruptive bug fix. Thanks!