Needs work
Project:
Drupal core
Version:
main
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Mar 2017 at 17:36 UTC
Updated:
6 Jul 2025 at 21:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
blazey commentedAttached patch changes the order in which ajax views are initialized.
Comment #3
blazey commentedComment #5
blazey commentedComment #6
Pavan B S commentedLine exceeding more than 80 characters
Applying the patch, please review.
Comment #7
stewestI can confirm that https://www.drupal.org/files/issues/2858890-2.patch does work for us! Nice work Blazey
Comment #8
stewestComment #9
alexpottWe can now write tests that leverage javascript. Yay! So we should add a test here to ensure we don't regress and have properly fixed this. See https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutorial
Comment #10
blazey commentedThanks for review @Pavan B S @stewest @alexpott. Attaching a test patch that:
test_view_area_ajax. It's just a simple content view with thetest_content_ajaxview embedded in the header.views_text_ajax_subscriberthat can do assertions on responses to ajax requests.EmbeddedViewPaginationAJAXTestjavascript test that visitstest_view_area_ajax, simulates a click on a pager link in the embedded view and tellsviews_text_ajax_subscribermodule to assert that the inner view, not the enclosing one, is associated with the request.Comment #13
blazey commentedAdded
@groupannotation.Comment #15
blazey commentedComment #16
blazey commented:)
Comment #18
blazey commentedComment #19
blazey commentedComment #21
flocondetoilePatch #13 won't apply on 8.4
Comment #22
flocondetoilePatch #13 rerolled against 8.4.2
Comment #24
GrandmaGlassesRopeManThese changes are against the transpiled code. Please make your changes against the
.es6.jsfiles and then transpile them. For more information have a look here, Drupal core now using ES6 for JavaScript development.Comment #25
netdreamer commentedEDITED: Skip this patch... look at #26
Patch #22 wasn't applicable on 8.5.x.
Now I've rerolled it against 8.5.1, with additional ajax_view.es6.js code transpiled to js
Comment #26
netdreamer commentedSorry, #25 was a bad file... reuploaded as #26
Comment #27
netdreamer commentedComment #28
eigentor commentedApplied the patch to Drupal 8.5.3 and can confirm it fixes the Ajax pager in nested views. I tested: 1 nesting level, tested normal mini pager and a Calendar view with Calendar pager.
Comment #29
blazey commentedAlso confirmed in #2853524: Replaces content, doesn't add, with embedded views.
Comment #30
GrandmaGlassesRopeManArrow function.
Need to add an exception because `ajaxView` is incorrectly cased for a constructor.
Should be an arrow function.
const.
Don't use a `for...in` loop, use an actual iterator.
If you use `Object.keys()` you won't need this.
Template strings.
Since you are just pushing a value, this entire thing can be replaced with `Array.map()`
Incorrect multi-line comment format.
You can probably just chain the `.sort()` and return it. Also use an arrow function for the handler.
You've changed this to `settings.selector` however the original variable is still around.
Comment #31
andersiversen commentedI've applied the patch in #26 and it fixes the problem for me.
My use case: I've a node where a field is using paragraphs so one can choose between different paragraph bundles. One of the bundles uses an entity reference field, to reference blocks. The block I'm referencing is made with views, it's a news feed with teasers, using views infinite scroll. Without the patch, the teasers are replaced when clicking load more, instead of being added to the bottom. With the patch it works.
Comment #33
zenimagine commentedUnable to apply the patch :
Comment #34
jasonlttl commentedArgh, bad patch. Missed new files. Ignore.
Patch in #26 was not applying vs 8.6. This hopefully fixes that, but doesn't address the code cleanup cited in #30.
Comment #35
jasonlttl commentedSecond try updating #26 for 8.6.x. Seems good (minus the changes needed from #30).
Comment #36
GrandmaGlassesRopeMan- reroll for 8.7.x
- resolves my review from #30
Comment #38
dawehnerI ran into this bug myself.
Here is the review of the current patch.
When trying out this patch I ran into an issue: ajaxViews is an object so .map fails.
Comment #41
handkerchiefAny news on this?
Comment #42
handkerchiefMy patch works for me with 8.7.7.
Sorry for only changing the ajax_view.js but ! needed a quick fix.
Comment #43
maurizio.ganovelliPatch #42 works for me but doesn't apply correctly.
Rerolled against 8.7.x branch.
Comment #45
lendudeThis is just a re-upload of #36 to prevent people from rerolling stuff that stripped away most of the relevant code in this fix.
#36 seems like the way forward since that has test coverage and es6, if there is an argument to use #42 please post a comment as to why we would use that. Just posting a short cut when there is an actual fix under discussion seems a little counter productive.
Comment #46
maurizio.ganovelliSorry Lendude, you're right.
In my case #36 not working correctly (same problem as #38). #42 works perfectly but doesn't apply (using composer with cweagans/composer-patches). #43 is same patch as #42 but apply flawlessly. I'm sorry that it strips away relevant code but, as specified in #42, it's a quick fix.
Thank you.
Comment #48
anybodyIsn't this related / duplicate? #2918352: After update to Drupal 8.4 VIC replace results instead of appending
Both have the nested views problem don't they? If yes, we should have a look and perhaps close the other?
Comment #49
handkerchiefHm I'm not sure Anybody. But what I can say: The patch #43 works well with 8.8.1.
It would be great if this fix can be commited.
Comment #51
anybodyI just tested patch #43 and #45 in combination with patch #19 from #2918352: After update to Drupal 8.4 VIC replace results instead of appending.
Patch #45 does NOT work in the current state!
Patch #44 (even if it's a workaround) fixes the problem!
Shouldn't we set this major, as it regular views ajax pager functionality is broken (for all pager types!) under given circumstances? For us it happened when using the view in layout_builder.
Comment #52
wadator commentedPatch #43 works for me but doesn't apply correctly.
Rerolled by 9.1.x branch.
Comment #53
anybodySetting priority to major as it prevents dependent modules from working like here: #2918352: After update to Drupal 8.4 VIC replace results instead of appending (also major issue)
Comment #55
daniel kulbeThe ES6 file should be edited to keep changes after transpilation in build steps. Made some optimisations, e.g. for...in should be avoided.
The once() call should go to the items itself, to be able to exclude them once the parent view get's initialised. There's no need to call once() on the view itself for the pager. I tried to align it a bit to the exposed form method.
Comment #56
daniel kulbeComment #58
daniel kulbeAJAX test was failing because of unwanted parameter.
Comment #60
daniel kulbeIs the AJAX test somehow outdated? "selector" is not a new key in element settings, but yet it is considered "unwanted" parameter!?
Comment #61
daniel kulbeComment #62
philsward commented2858890-58--8.9.x.patch seems to work great with #42 from #2833734: Add pager per each Views attachment display
Comment #63
artusamakI also confirm for Drupal 9.1.x + #2858890-58 + #2833734-42 are fixing the issue.
Comment #64
anybodyI can also confirm #58 to work with 9.15! Any idea how to proceed here with the failed patch or who to ask for the problems?
Comment #66
golddragon007 commented2833734 #42 + 2858890 #58 It shows up the pager, however, when I use the infinite scroll pager, and I have a block with an attachment (after) than when I load for the main block or the attachment more items with the pager, it's added to the other list too. That's not good. But I wonder if this is not a bug in the infinite scroll to target wrongly the container.
Comment #67
rcodinaPatches #2833734-42 + #2858890-58 are fixing the issue for Drupal 9.2.x.
Comment #69
anybody#58 doesn't apply anymore for Drupal Core 9.3.x
Comment #70
karishmaamin commentedTried re-rolling patch. Please review.
Comment #71
gresko8 commentedFixing missing parentheses/semicolons in the patch from comment #70
Comment #72
ecosty commentedThis one worked for me with 9.3.0 version. Thanks for adding the patch.
Comment #73
anybodyAny plans to push things forward in core and views infinite scroll to get this nasty and years old major bug away?
What would be needed is feedback if the current approach is the right way to go or if it should be solved differently in general? Who can decide that?
I'd like to help in code to fix this, but it doesn't make sense without feedback for the current patch...
This patch seems to be used by many Drupal users and is rerolled again and again... to be honest we couldn't ever use views_infinite_scroll correctly without the two patches mentioned above...
Comment #74
gresko8 commentedAttaching a new patch fixing missing line in attachExposedFormAjax, causing exposed filters not firing ajax callback and reloading the whole page.
Comment #75
ranjith_kumar_k_u commentedComment #77
vacho commentedPatches 74, 75 make one issue on ajax at a time to add media fields to nodes.
Comment #78
tetranz commentedI can confirm what #77 is saying. Patches 74 and 75 cause a critical problem with media library on Drupal 9.3.
To reproduce this, create a content type with an image media reference and use the media library widget.
When you "Insert selected" in the media widget to add an image, it causes an extra irrelevant ajax request which responds with a redirect to a 404.
After that, the image seems to be inserted okay but then you can't save the node. A similar irrelevant ajax request happens when you click Save. This crashes, preventing the node from being saved. I think a selector needs to be more specific.
Patch 71 seems to work okay on Drupal 9.3.
Comment #79
prudloff commentedThe attached patch fixes the problem explained in #78.
In a
forEach()callback, the first argument is the item, not the second one. The jQuery selector was getting every submit input in the page, now it only applies to the current form.Comment #81
jds1This works great for me. The Media Library brokenness was a real trip, but I think we're all set here now.
Comment #83
anybodyThank you very much @prudloff, what about the failing 18 Tests? #44 had all tests green.
@if-jds: This can't be RTBC'd until all tests pass!
Comment #84
anybodyIndeed #74, #75 broke the media library widget and lead to: #3263896: Media library browser selection returns statuscode 303 on AJAX
Huge thanks to @nsavitsky for pointing me into this direction!
Comment #86
rob230 commentedIt's quite major to have either load more AJAX or the media library broken, so I've tried to fix this. I simply made it use the new code if the views infinite scroll container is inside the view. There may be a better way of doing this but at least in my testing it now works in both scenarios.
Comment #87
ranjith_kumar_k_u commentedComment #89
nsalves commentedI can confirm that #81 fixed my problems with the media library widget. We also tried #86 that fixed the problems with the filter but broke pagination.
Comment #90
a.hover commentedThis is just an update of @Rob230's patch above. The new patch:
Comment #91
rob230 commentedThere is a further issue here, whereby entity browser's filters were broken. I tracked down the problem to the changes to the
Drupal.views.ajaxView.prototype.attachExposedFormAjaxfunction, specifically the fact it now takesformas an argument. In entity_browser.view.js it callsattachExposedFormAjaxbut the argument passed is 0.Obviously this is a core bug so we can't modify the entity_browser module. The issue here is that a breaking change has been made to Drupal functions which other modules may be calling.
My fix for this is just to add a check on the form value and if it's empty set it to what it would be in the unpatched core:
this.$exposed_formThe concern is are there other places where the prototype functions have been changed which other modules might be using.
Comment #92
anybodyConfirming the issues with entity_browser mentioned in #90 and #91.
#91 looks like a clever solution and works for me. So setting this back to "Needs review". Thanks @Rob230 once again!
RTBC+1 from my side and I agree with the major priority due to the current situation.
Comment #94
anybody#91 sadly does not apply anymore.
Comment #95
anybodyRerolled #91 against 10.1.x as MR. Please let's proceed in MR's instead of patches for the work to be committed. Patches for 9.x versions are of course welcome based on the MR.
Comment #97
grevil commentedMR LGTM!
Retesting it for Drupal 10.1.x to be 100% sure.
Comment #98
grevil commentedCrazy, ESLint validation is finally part of Drupal's Jenkins validation, very nice!!
Comment #100
grevil commentedHm, I get a different ESLint errors/warnings, when running ESLint locally using "core/.eslintrc.json" in Drupal 10.1.x:
Otherwise, the MR seems fine!
Comment #101
ciprian.jitaru commentedI've updated the patch from @Rob230 to work with Drupal 9.5.1
Comment #102
_utsavsharma commentedComment #103
_utsavsharma commentedTried to fix CCF for #101.
Comment #107
capysara commentedRebased against the most recent 10.1.x codebase.
Comment #109
ckngWith patch #103, works after cleared cache. However, issue reappears after some time. Caching issue?
Comment #110
grevil commented@Anybody can you cherry-pick https://git.drupalcode.org/project/drupal/-/merge_requests/3125/diffs?co... to the 9.5.x branch? I think only the issue branch creator can cherry-pick for some reason.
EDIT: Here is the commit directly: https://git.drupalcode.org/project/drupal/-/commit/4474784449c38cae17790...
Comment #111
grevil commentedUnsure about patches #101 and #103. There is a 9.5.x branch in https://git.drupalcode.org/issue/drupal-2858890/-/tree/2858890-9.5.x-vie.... Are your patches based on the diff of this branch? Let's not spread further confusion and finally resolve this year-old issue. Please work on the provided issue branches, thanks! 🙂
Comment #112
grevil commented@ckng can you confirm this issue still exists with the diff of 9.5.x applied as a patch, once @Anybody cherry picks @nsciacca "once" change?
https://git.drupalcode.org/project/drupal/-/merge_requests/3126.diff
Comment #113
anybody@Grevil: No, sadly no such option. Can only be done manually or by patch, sorry.
Comment #114
grevil commentedOk something went wrong here...

Comment #115
grevil commentedAlright! Everything should be cleared up now! I manually applied the relevant changes of https://git.drupalcode.org/project/drupal/-/merge_requests/3125/diffs?co... by @nsciacca and fixed the 11.x branch again! The main problem, was that 11.x ditches the old "ajax_view.js" in favour of "ajax_view.es6.js".
Please review!
Comment #116
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #117
grevil commentedHow annoying... "MR !3126" can not be applied to 11.x as it is the 9.5.x feature branch... Going to close the MR for now in hopes the bot won't set it to "Needs work" again.
Comment #119
smustgrave commentedCan the issue summary be updated with steps to reproduce. Also the link is pointing to 8.4 so definitely outdated.
Comment #120
smustgrave commentedAlso as a bug will need a test case.
Comment #121
grevil commentedOK, it seems that all patches after "drupal-2858890-79.patch" by @prudloff explicitly check for the ".views-infinite-scroll-content-wrapper". This definitely be avoided inside a core issue.
Comment #122
grevil commentedIt also seems that patch 86 was originally created without a reason? From the conversation, the original problem with the broken media library got fixed with patch 79 and there were only tests left to fix. Then suddenly patch 86 got introduced with the same goal to fix the media library, which introduced the check for ".views-infinite-scroll-content-wrapper".
Comment #123
grevil commentedI'll create a second branch with the changes from patch 79 and see how that goes.
EDIT: Note, that all failing tests for patch 79 are unrelated deprecation notices.
Comment #125
grevil commentedLet's see if tests succeed on that branch as well (1 failing test is expected, which needs to be refactored).
Comment #127
grevil commentedAlright! Infinite scroll works again in conjunction with the latest issue fork changes from #2918352: After update to Drupal 8.4 VIC replace results instead of appending for 11.x! :)
Now let's see, what the tests say, and then we can create a fork, to backport the changes for 10.1.x as well!
(We of course also need independent tests, not including any infinite scroll stuff)
Comment #128
grevil commentedComment #130
grevil commentedI don't know, how to properly test this, so I am leaving this issue on "Needs work" for people to create tests.
(For all infinite scroll users, coming from #2918352: After update to Drupal 8.4 VIC replace results instead of appending, this core patch seems to not be needed any more for Drupal 10.x)
I am removing the "major" priority, as it wasn't major to begin with.
Comment #131
grevil commentedUpdate to my comment in #127. The issue in #2918352: After update to Drupal 8.4 VIC replace results instead of appending isn't a thing anymore, it works just fine in current 2.0.x.
Meaning that the manual testing I did for this issue was incorrect... 🫠
So if anyone runs into this issue, please test the current issue branches, and see, if it fixes the problem for you:
If so, it would be really nice, to add the steps you took inside the issue summary's "Steps to reproduce" section. And if you can also write tests, please verify the fixed behavior through tests!
Thanks.
Comment #133
maximkashubarebased 2858890-views-ajax-fix-init-in-nested-views-patch-79 branch from 10.1.x to make the changes applicable.
Comment #134
nsciaccaThe patch/MR works on 10.1 however it breaks the entity_browser modal pop up. Anyone else use both and found a solution? I tried using the patch in 91 but it didn't work to fix the pager issue on the newer code base.
Update: I added some additional selectors to exclude in the attachExposedFormAjax .not to fix the issue with Entity Browser:
.not('[data-drupal-selector=edit-reset],[data-drupal-selector^="edit-tab-selector"],.is-entity-browser-submit')
Comment #136
nsciaccaI opened another MR for the 10.2.x branch as neither existing MR/patch was applying cleanly. Includes my modification with the extra selectors that were breaking Entity Browser.
Comment #137
rob230 commentedMerge request !5867 doesn't apply to Drupal 10.2.2.
Edit: actually it does work. I don't know what the problem was before. I downloaded the diff again via wget and it applied.
Comment #139
johnvComment #142
prudloff commentedComment #143
prudloff commentedIt looks like patches used to have tests but they were dropped starting with comment 42.
I added them back.
Comment #144
smustgrave commentedleft a small comment on the MR but leaving in review
Comment #145
smustgrave commentedSince it's been 2 months left some comments on the MR around the tests.