Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After update to Drupal 8.4 Views Infinity Scroll replaces view with new set of results instead of appending it. Instead of showing 9 + 9 + 9 etc. (total 27 tiems) it basically now it works as pager showing 9 items, then next 9 items and etc. (always only certain amount of items).
Comment | File | Size | Author |
---|---|---|---|
#48 | infinite.patch | 1.29 KB | Anonymous (not verified) |
#14 | filter-nested-views-2918352-14.patch | 1.96 KB | Daniel Kulbe |
| |||
#10 | filter-nested-views-2918352-10.patch | 1.97 KB | Daniel Kulbe |
|
Issue fork views_infinite_scroll-2918352
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
Comment #2
monkk CreditAttribution: monkk commentedComment #3
netdreamer CreditAttribution: netdreamer commentedI confirm the issue, but I'm not sure about why it happens.
I've been able to restrict the bug search to two repeatable use cases:
So, I think that:
I suppose that it should be only a jquery div selection issue, that fails in the case of a child view in the main view.
I also confirm that before 8.4 it was working, also on second use case.
Hope it helps... I'll continue to test the issue...
Comment #4
megan_m CreditAttribution: megan_m commentedMy pager doesn't work at all - a simple view, with the pager set to load on click.
I got this error in the console:
Uncaught TypeError: Cannot read property 'replace' of undefined in infinite-scroll.js?v=8.4.0:29
That line is using jQuery .selector, which was removed in jQuery 3.x. Drupal 8.4 updated to jQuery 3.2.
This line is fixed in the dev version.
Comment #5
netdreamer CreditAttribution: netdreamer commentedI finally found that js is loaded, but not invoked at all (that's why it paginate as a standard ajax view ...)!
The issue is in function onResponse, in src/EventSubscriber/AjaxResponseSubscriber.php, near line 52:
At the moment I still don't know why, but $view->getPager()->getPluginId() is null, not 'infinite_scroll', so the function returns immediately and the following alterPaginationCommands is not executed (= infinite ajax is not called...)
As a test, I tried to "force" the execution by commenting the "if" sentence and infinite scroll started working again (don't do it at home, it will affect every paginator!)
BUT, i still have to understand why getPluginID() is null... and I also suspect that getPager() is not ok...
Comment #6
netdreamer CreditAttribution: netdreamer commented@megan_m I think you are using an old version of the module.
That line was fixed in 1.4 ( commit http://cgit.drupalcode.org/views_infinite_scroll/commit/?id=e1dd539bc2dd... , fixed in #2902796: Stopped working with Views 3.17 )
Comment #7
netdreamer CreditAttribution: netdreamer commentedBack to my use case: one view without pager containing an attached view block with pager.
I discovered why it fails: $view->getPager()->getPluginId() is null and not 'infinite_scroll' because it is always referring to MAIN view. It's easy to see it in the Ajax request that gets generated when you click on ANY pager, not only infinitescroll type (url: /views/ajax?_wrapper_format=drupal_ajax ... I removed not useful lines...)
So, the code in src/EventSubscriber/AjaxResponseSubscriber.php line 52, will NEVER be able to run, because $view->getPager()->getPluginId() contains the pager plugin id of the MAIN view (in my usecase, "none"), not the embedded one...
It's necessary to replace the way in which we are checking if pager is infinite_scroll, but I'm not sure it is something that can be done INSIDE VIC.
I found this, where the issue is really the same, for generic pagers... #1082334-12: Separate pagers for default display and attachment display
Comment #8
tomdewild CreditAttribution: tomdewild commentedThanks for opening this issue. I had the same problem but I eventually resolved it by turning on the use of AJAX.
Comment #9
goodDenis CreditAttribution: goodDenis as a volunteer commentedSetting "Use AJAX" in view helped me too.
Comment #10
Daniel KulbeI attached a new the patch 26 to https://www.drupal.org/project/drupal/issues/2833734, to allow separate pagers for attachments.
So VIS should implement similar filter function which ensures only the rows and pager which are direct target of the AJAX call will be updated.
Comment #11
Honza Pobořil CreditAttribution: Honza Pobořil as a volunteer commentedIs this bug also in 1.5 or it was introduced later?
If you will not reply in a ~week I will release 1.6 from the current dev.
Comment #12
brooke_heaton CreditAttribution: brooke_heaton commentedPatch #10 no longer applies clean for me.
Comment #13
Dinesh18 CreditAttribution: Dinesh18 as a volunteer commentedAny idea for D7, I want to make the rows append instead of replacing. Is there any patch available for D7
Comment #14
Daniel KulbeRerolled patch against latest code.
Comment #15
AnybodyDoes #14 still work?
Comment #16
AnybodyComment #17
AnybodyIs this a duplicate of #2858890: Drupal.views.ajaxView is not initializing pagers in nested views?
Comment #18
Bao Truong CreditAttribution: Bao Truong commentedThanks so much for working on this issue everyone. I was able to create a patch against the latest dev version. Hopefully this works for everyone.
Comment #19
Bao Truong CreditAttribution: Bao Truong commentedHey Everyone,
Here is another patch rerolled that includes a solve for another issue "Headers in table format repeat on load more instead of adding rows" at https://www.drupal.org/node/2899705
Applying this patch now solves for both issues in case anyone is needing it and is having trouble applying patches from both issues. You should now be able to apply this patch and solve both issues.
Comment #20
AnybodyOk here's my final result after testing #19 with a view in layout_builder.
It works combined with #2858890: Drupal.views.ajaxView is not initializing pagers in nested views, Patch #43. Without that additional core patch it does NOT work. Also the core patch alone doesn't fix the problem for me.
RTBC+1 for #19 so, please help to move the core patch to a commit.
Comment #21
AnybodyThis is major because functionality is completely broken on the given conditions and there's no workaround for a regular user.
Comment #22
Neslee Canil Pinto@Anybody dont you think we need to wait till #2858890: Drupal.views.ajaxView is not initializing pagers in nested views will be committed into drupal core?
Comment #23
Anybody@Neslee Canil Pinto, yes I agree, but can't see any progress there.
Let's postpone it on #2858890: Drupal.views.ajaxView is not initializing pagers in nested views as of #20-#22.
Anyway it's still major from my perspective as written above, which is a strange situation.
Comment #24
Daniel KulbeI guess the issues are somehow related, but #2858890 can not solve the issue. I updated this patch for my latest changes in that ticket.
Secondly it appears to be important to have pager ID to "0" for all views blocks, if they are on the same page. In case you have set a value > 0, the RequestSubscriber of VIS will fail, because the
page
query parameter looks like?page=,1,,1
so$event->getRequest()->query->get('page') == 0
isTRUE
.I would also like to leave changes made in #2899705 out of this as long as it is not in master. If you need both changes in your code, @Bao Truong, I suggest a custom local patch.
Comment #25
acbramley CreditAttribution: acbramley at PreviousNext for Service NSW commentedI'm getting this issue after updating to 1.8.0 but it doesn't occcur in 1.7.0
The view is a very simple block, but it does have an overridden pager ID as described in #24.
Changing the pager ID to 0 fixes it in 1.8.0, but it would be good to figure out why this regressed between the versions.
Comment #26
rcodina CreditAttribution: rcodina commentedI have had to downgrade to 1.7.0 to fix the problem. Changing the pager ID to 0 hasn't fixed the bug for me.
Comment #27
vuilWe have the same issue with 1.8 version. The issue does not exist with 1.7 version.
I set the issue status to Needs work.
Comment #28
AnybodyAs 2.0.x is the new branch where development happens, I'll switch over.
Comment #29
olivier.br CreditAttribution: olivier.br commentedHaving this issue with the pagination of a nested view (embed display).
updated patch for 2.0.x.
I had to apply also the patch from core issue #2858890 and #2833734
Comment #30
tjmoyer CreditAttribution: tjmoyer at Mindgrub Technologies commentedThere's an error with the last patch (for 2.0.x) that caused it not to load more results (there is no $pager_links variable). Here's a patch new patch for 2.0.x that does not change that line and seems to work, at least in our case.
Comment #33
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedSwitching to an issue fork workflow.
Comment #34
AnybodyComment #35
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedSince patch "filter-nested-views-2918352-30.patch" doesn't work any more in conjunction with the latest patch of #2858890: Drupal.views.ajaxView is not initializing pagers in nested views, I manually applied the last RTBC'd patch (filter-nested-views-2918352-19.patch) to this issue's fork, as no other patch after that patch provided an interdiff, it is hard to tell if it introduced any regression.
Comment #36
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedAlright, fixed the upstream core issue for 11.x! Works great, with the changes from the issue fork. Now we need to backport #2858890: Drupal.views.ajaxView is not initializing pagers in nested views to 10.1.x, create tests here and create a new SemVer branch, based on the Drupal version #2858890: Drupal.views.ajaxView is not initializing pagers in nested views gets commited to.
Comment #37
AnybodyThanks @Grevil for working on this! The good news is, that it even works without the core patch, which simplifies things a lot. Even with the core patch, it still works, as @Grevil confirmed.
So we only need a test now to prove it works and didn't work before and then we can finally fix this old major issue!
Attaching the current MR state as static patch for composer.
Comment #38
AnybodyHiding all patches to proceed in the MR finally.
Comment #39
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedInteresting, the tests do not run at all under Drupal 10 and fixing the test theme, will make them "properly" fail:
(without the changes from this issue)
UPDATE: The custom assertion methods use theme specific classes, which are not available in "stark", using "starterkit_theme" for a replacement for "classy" instead of "stark"
Comment #40
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedI don't get it, "testInfiniteScroll()" inside "tests/src/FunctionalJavascript/InfiniteScrollTest.php" should already fail right now... but it doesn't for some reason...
Here is a patch with only the tests adjusted, but without the changes from this issue (which should fail rn).
EDIT: They succeed, but failing was expected.
Comment #41
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedMy apologies, the test doesn't specifically test views inside views...
That's why the tests succeed.
Comment #42
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedOk, @Anybody and I just tested this extensively, and it seems the problem doesn't exist anymore for 2.0.x!
We used the drupal core "glossary" view and changed the pager to use infinity scroll, and everything worked as expected!
These are the pager settings we used:
After I got on the "/glossary" page and pressed "Load more" a few times, this was the output:
Note, that the duplicate table headers are unrelated (This is a different issue #2899705: Headers in table format repeat on load more instead of adding rows).
This might still be an issue related to 8.x-1.x, so I will set the version appropriately and postpone this issue, for people to still see this issue, when running into this again.
EDIT: We also tested all formatters with only the pager set (without the attachment, leading to not having a view inside a view). That also worked just fine!
Comment #43
vuilThe issue does not exist in the latest 2.0.x branch. But it can be committed into 8.x-1.x branch.
Comment #44
Anybody@Grevil: See #43 - what should we do here?
I don't think we should touch 8.x-1.x.
Still there are changes in the MR against 2.x?
Comment #45
Anybody@Grevil: Without the fixes here, the tests in 2.x are broken... so should we merge this into 2.x or better create a separate issue to fix the tests and close this one as the issue seems to be fixed in 2.x as of #43?
Comment #46
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedYes, the issue is fixed and not present anymore in 2.0.x. Drupal 8 is EOL, so we shouldn't make any changes inside 1.x anymore.
Apart from the theme switch, nothing in here is worth committing.
Let's close it.
Comment #47
AnybodyOk, should someone encounter the same in 2.x, feel free to reopen with clear steps to reproduce. Thanks!
Comment #48
Anonymous (not verified) CreditAttribution: Anonymous commentedWe used the drupal core "glossary" view and changed the pager to use infinity scroll, and remaining things as expected.
We also tested all formatters with only the pager set. That also worked just fine.