Problem/Motivation

Drupal.views.ajaxView is not initializing pagers in nested views. In ajax_view.js, filterNestedViews() checks if view is inside another view. As a result pager links in embedded views are initialized in the context of parent. This makes it impossible to perform ajax operations in context of the child view (see this Views Infinite Scroll issue).

Steps to reproduce

  1. Create a view with two displays : a page and an embed.
  2. Disable AJAX on the page display and enable AJAX on the embed display.
  3. Add the embed display in the header area of the page display.
  4. Display the page and use the pager of the embed display: it does not have AJAX though AJAX is enabled on it.

Proposed resolution

Initialize ajax views in order determined by their nesting level. The innermost view should go first and mark its elements with .once so they aren't processed again when parent view is initialized.

Remaining tasks

  1. Write patch
  2. Review
  3. Write tests

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#116 2858890-nr-bot.txt90 bytesneeds-review-queue-bot
#114 2023-06-16 16_08_09-Issue #2858890_ Drupal.views_.ajaxView is not initializing pagers in nested views.png21.83 KBgrevil
#103 2858890-103.patch8.8 KB_utsavsharma
#103 interdiff_101-103.txt4.42 KB_utsavsharma
#101 drupal-2858890.patch9.83 KBciprian.jitaru
#91 interdiff-2858890-90-91.txt1.15 KBrob230
#91 drupal-2858890-91.patch10.17 KBrob230
#90 drupal-2858890-90.patch10.06 KBa.hover
#87 interdiff_86-87.txt1.42 KBranjith_kumar_k_u
#87 2858890-87.patch9.58 KBranjith_kumar_k_u
#86 interdiff-2858890-79-86.txt2.44 KBrob230
#86 drupal-2858890-86.patch9.59 KBrob230
#79 interdiff-2858890-75-79.txt1.15 KBprudloff
#79 drupal-2858890-79.patch8.95 KBprudloff
#75 interdiff_74-75.txt5.43 KBranjith_kumar_k_u
#75 2858890-75.patch9.03 KBranjith_kumar_k_u
#74 2858890-74.patch9.24 KBgresko8
#71 2858890-71.patch9.14 KBgresko8
#70 2858890-70.patch9.13 KBkarishmaamin
#58 2858890-58--8.9.x.patch8.67 KBdaniel kulbe
#58 2858890-58.patch9.12 KBdaniel kulbe
#56 2858890-55--9.2.x.patch8.43 KBdaniel kulbe
#55 2858890-55.patch7.96 KBdaniel kulbe
#52 2858890-52.patch3.07 KBwadator
#45 2858890-36.patch17.64 KBlendude
#43 2858890-43.patch2.85 KBmaurizio.ganovelli
#42 2858890-42.patch2.99 KBhandkerchief
#36 2858890-36.patch17.64 KBGrandmaGlassesRopeMan
#35 2858890-35.patch16.34 KBjasonlttl
#34 2858890-34.patch5.81 KBjasonlttl
#26 2858890-26.patch16.76 KBnetdreamer
#25 2858890-25.patch16.74 KBnetdreamer
#22 2858890-22.patch13.84 KBflocondetoile
#16 2858890-15-test-only.patch10.5 KBblazey
#15 2858890-15-test-only.patch10.5 KBblazey
#13 interdiff-10-13.txt678 bytesblazey
#13 2858890-13.patch14.09 KBblazey
#13 2858890-13-test-only.patch10.5 KBblazey
#10 2858890-10.patch14.01 KBblazey
#10 2858890-10-test-only.patch10.43 KBblazey
#6 interdif2.txt492 bytesPavan B S
#6 2858890-7.patch3.58 KBPavan B S
#5 interdiff-2-5.txt1.18 KBblazey
#5 2858890-5.patch3.58 KBblazey
#2 2858890-2.patch3.54 KBblazey

Issue fork drupal-2858890

Command icon 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

blazey created an issue. See original summary.

blazey’s picture

StatusFileSize
new3.54 KB

Attached patch changes the order in which ajax views are initialized.

blazey’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2858890-2.patch, failed testing.

blazey’s picture

Assigned: blazey » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new3.58 KB
new1.18 KB
Pavan B S’s picture

StatusFileSize
new3.58 KB
new492 bytes
+++ b/core/modules/views/js/ajax_view.js
@@ -38,6 +35,35 @@
+    // Sort views by nesting level descending. The goal is to start with the innermost.

Line exceeding more than 80 characters
Applying the patch, please review.

stewest’s picture

I can confirm that https://www.drupal.org/files/issues/2858890-2.patch does work for us! Nice work Blazey

stewest’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We 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

blazey’s picture

Status: Needs work » Needs review
StatusFileSize
new10.43 KB
new14.01 KB

Thanks for review @Pavan B S @stewest @alexpott. Attaching a test patch that:

  • Adds a new test view test_view_area_ajax. It's just a simple content view with the test_content_ajax view embedded in the header.
  • Adds a new module views_text_ajax_subscriber that can do assertions on responses to ajax requests.
  • Adds a new EmbeddedViewPaginationAJAXTest javascript test that visits test_view_area_ajax, simulates a click on a pager link in the embedded view and tells views_text_ajax_subscriber module to assert that the inner view, not the enclosing one, is associated with the request.

The last submitted patch, 10: 2858890-10-test-only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: 2858890-10.patch, failed testing.

blazey’s picture

Status: Needs work » Needs review
StatusFileSize
new10.5 KB
new14.09 KB
new678 bytes

Added @group annotation.

The last submitted patch, 13: 2858890-13-test-only.patch, failed testing.

blazey’s picture

StatusFileSize
new10.5 KB
blazey’s picture

StatusFileSize
new10.5 KB

:)

Status: Needs review » Needs work

The last submitted patch, 16: 2858890-15-test-only.patch, failed testing.

blazey’s picture

Status: Needs work » Needs review
blazey’s picture

Issue tags: -Needs tests +JavaScript

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

flocondetoile’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch #13 won't apply on 8.4

flocondetoile’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new13.84 KB

Patch #13 rerolled against 8.4.2

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

GrandmaGlassesRopeMan’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Needs review » Needs work
diff --git a/core/modules/views/js/ajax_view.js b/core/modules/views/js/ajax_view.js

These changes are against the transpiled code. Please make your changes against the .es6.js files and then transpile them. For more information have a look here, Drupal core now using ES6 for JavaScript development.

netdreamer’s picture

StatusFileSize
new16.74 KB

EDITED: 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

netdreamer’s picture

StatusFileSize
new16.76 KB

Sorry, #25 was a bad file... reuploaded as #26

netdreamer’s picture

Status: Needs work » Needs review
eigentor’s picture

Applied 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.

blazey’s picture

Status: Needs review » Reviewed & tested by the community
GrandmaGlassesRopeMan’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -15,9 +15,8 @@
    +      Drupal.views.sortByNestingLevel(drupalSettings.views.ajaxViews).forEach(function (item) {
    

    Arrow function.

  2. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -15,9 +15,8 @@
    +        Drupal.views.instances[item.key] = new Drupal.views.ajaxView(item.value);
    

    Need to add an exception because `ajaxView` is incorrectly cased for a constructor.

  3. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +  Drupal.views.sortByNestingLevel = function (ajaxViews) {
    

    Should be an arrow function.

  4. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +    var ajaxViewsArray = [];
    

    const.

  5. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +    for (var i in ajaxViews) {
    

    Don't use a `for...in` loop, use an actual iterator.

  6. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +      if (ajaxViews.hasOwnProperty(i)) {
    

    If you use `Object.keys()` you won't need this.

  7. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +        ajaxViews[i].selector = '.js-view-dom-id-' + ajaxViews[i].view_dom_id;
    

    Template strings.

  8. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +        ajaxViewsArray.push({
    +          key: i,
    +          value: ajaxViews[i],
    +          nestingLevel: $(ajaxViews[i].selector).parents('.view').length
    +        });
    

    Since you are just pushing a value, this entire thing can be replaced with `Array.map()`

  9. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +    // Sort views by nesting level descending. The goal is to start with the
    +    // innermost.
    

    Incorrect multi-line comment format.

  10. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -33,6 +32,36 @@
    +    return ajaxViewsArray.sort(function (a, b) {
    +      return b.nestingLevel - a.nestingLevel;
    +    });
    

    You can probably just chain the `.sort()` and return it. Also use an arrow function for the handler.

  11. +++ b/core/modules/views/js/ajax_view.es6.js
    @@ -72,7 +101,7 @@
    +      selector: settings.selector,
    

    You've changed this to `settings.selector` however the original variable is still around.

andersiversen’s picture

I'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.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

zenimagine’s picture

Unable to apply the patch :

  - Installing drupal/views_infinite_scroll (dev-1.x 74c9ba8): Cloning 74c9ba8668 from cache
  - Applying patches for drupal/views_infinite_scroll
    https://www.drupal.org/files/issues/2018-03-29/2858890-26.patch (Drupal.views.ajaxView is not initializing pagers in nested views)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2018-03-29/2858890-26.patch
jasonlttl’s picture

StatusFileSize
new5.81 KB

Argh, 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.

jasonlttl’s picture

StatusFileSize
new16.34 KB

Second try updating #26 for 8.6.x. Seems good (minus the changes needed from #30).

GrandmaGlassesRopeMan’s picture

Status: Needs work » Needs review
StatusFileSize
new17.64 KB

- reroll for 8.7.x
- resolves my review from #30

Status: Needs review » Needs work

The last submitted patch, 36: 2858890-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

dawehner’s picture

I ran into this bug myself.

Here is the review of the current patch.

+++ b/core/modules/views/js/ajax_view.es6.js
@@ -50,6 +53,29 @@
+    ajaxViews
+      .map(ajaxView => ({

When trying out this patch I ran into an issue: ajaxViews is an object so .map fails.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

handkerchief’s picture

Issue tags: -JavaScript +JavaScript

Any news on this?

handkerchief’s picture

Status: Needs work » Needs review
StatusFileSize
new2.99 KB

My patch works for me with 8.7.7.
Sorry for only changing the ajax_view.js but ! needed a quick fix.

maurizio.ganovelli’s picture

StatusFileSize
new2.85 KB

Patch #42 works for me but doesn't apply correctly.
Rerolled against 8.7.x branch.

Status: Needs review » Needs work

The last submitted patch, 43: 2858890-43.patch, failed testing. View results

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new17.64 KB

This 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.

maurizio.ganovelli’s picture

Sorry 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.

Status: Needs review » Needs work

The last submitted patch, 45: 2858890-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

anybody’s picture

Isn'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?

handkerchief’s picture

Hm 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.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

anybody’s picture

I 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.

wadator’s picture

StatusFileSize
new3.07 KB

Patch #43 works for me but doesn't apply correctly.
Rerolled by 9.1.x branch.

anybody’s picture

Priority: Normal » Major

Setting 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)

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

daniel kulbe’s picture

Status: Needs work » Needs review
StatusFileSize
new7.96 KB

The 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.

daniel kulbe’s picture

StatusFileSize
new8.43 KB

Status: Needs review » Needs work

The last submitted patch, 56: 2858890-55--9.2.x.patch, failed testing. View results

daniel kulbe’s picture

Status: Needs work » Needs review
StatusFileSize
new9.12 KB
new8.67 KB

AJAX test was failing because of unwanted parameter.

The last submitted patch, 58: 2858890-58.patch, failed testing. View results

daniel kulbe’s picture

Is the AJAX test somehow outdated? "selector" is not a new key in element settings, but yet it is considered "unwanted" parameter!?

daniel kulbe’s picture

philsward’s picture

2858890-58--8.9.x.patch seems to work great with #42 from #2833734: Add pager per each Views attachment display

artusamak’s picture

I also confirm for Drupal 9.1.x + #2858890-58 + #2833734-42 are fixing the issue.

anybody’s picture

I 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?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

golddragon007’s picture

2833734 #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.

rcodina’s picture

Patches #2833734-42 + #2858890-58 are fixing the issue for Drupal 9.2.x.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

#58 doesn't apply anymore for Drupal Core 9.3.x

karishmaamin’s picture

StatusFileSize
new9.13 KB

Tried re-rolling patch. Please review.

gresko8’s picture

Status: Needs work » Needs review
StatusFileSize
new9.14 KB

Fixing missing parentheses/semicolons in the patch from comment #70

ecosty’s picture

This one worked for me with 9.3.0 version. Thanks for adding the patch.

anybody’s picture

Issue tags: -Needs reroll

Any 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...

gresko8’s picture

StatusFileSize
new9.24 KB

Attaching a new patch fixing missing line in attachExposedFormAjax, causing exposed filters not firing ajax callback and reloading the whole page.

ranjith_kumar_k_u’s picture

StatusFileSize
new9.03 KB
new5.43 KB

Status: Needs review » Needs work

The last submitted patch, 75: 2858890-75.patch, failed testing. View results

vacho’s picture

Patches 74, 75 make one issue on ajax at a time to add media fields to nodes.

tetranz’s picture

I 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.

prudloff’s picture

Status: Needs work » Needs review
StatusFileSize
new8.95 KB
new1.15 KB

The 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.

Status: Needs review » Needs work

The last submitted patch, 79: drupal-2858890-79.patch, failed testing. View results

jds1’s picture

Status: Needs work » Reviewed & tested by the community

This works great for me. The Media Library brokenness was a real trip, but I think we're all set here now.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 79: drupal-2858890-79.patch, failed testing. View results

anybody’s picture

Thank 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!

anybody’s picture

Indeed #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!

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rob230’s picture

Status: Needs work » Needs review
StatusFileSize
new9.59 KB
new2.44 KB

It'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.

ranjith_kumar_k_u’s picture

StatusFileSize
new9.58 KB
new1.42 KB

Status: Needs review » Needs work

The last submitted patch, 87: 2858890-87.patch, failed testing. View results

nsalves’s picture

I 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.

a.hover’s picture

StatusFileSize
new10.06 KB

This is just an update of @Rob230's patch above. The new patch:

  1. Re-instates the functions that the code in the non-Infinite Scroll "else" was still using, but which were removed elsewhere in the patch - This should solve the pagination issue Nelson mentions in #89
  2. Adds in an exclusion for Entity Browser tab's hidden buttons to prevent them from being targeted by the "attachExposedFormAjax" function. Without this, it wasn't possible to switch tabs once the fix in point 1 was implemented.
rob230’s picture

StatusFileSize
new10.17 KB
new1.15 KB

There 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.attachExposedFormAjax function, specifically the fact it now takes form as an argument. In entity_browser.view.js it calls attachExposedFormAjax but 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_form

The concern is are there other places where the prototype functions have been changed which other modules might be using.

anybody’s picture

Status: Needs work » Needs review

Confirming 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.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Status: Needs review » Needs work

#91 sadly does not apply anymore.

anybody’s picture

Status: Needs work » Needs review

Rerolled #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.

grevil’s picture

MR LGTM!

Retesting it for Drupal 10.1.x to be 100% sure.

grevil’s picture

Status: Needs review » Needs work

Crazy, ESLint validation is finally part of Drupal's Jenkins validation, very nice!!

grevil’s picture

Hm, I get a different ESLint errors/warnings, when running ESLint locally using "core/.eslintrc.json" in Drupal 10.1.x:

/var/www/html/drupal-2858890/core/modules/views/js/ajax_view.js
    6:2   warning  Unexpected unnamed function                                  func-names
   16:43  warning  Unexpected unnamed function                                  func-names
   22:56  error    A constructor name should not start with a lowercase letter  new-cap
   66:37  warning  Unexpected unnamed function                                  func-names
   89:27  warning  Unexpected unnamed function                                  func-names
   99:7   error    Use array destructuring                                      prefer-destructuring
  172:3   warning  Missing JSDoc for parameter 'form'                           valid-jsdoc
  179:59  warning  Unexpected unnamed function                                  func-names
  205:55  warning  Unexpected unnamed function                                  func-names
  214:53  warning  Unexpected unnamed function                                  func-names
  230:57  warning  Unexpected unnamed function                                  func-names
  264:50  warning  Unexpected unnamed function                                  func-names

✖ 12 problems (2 errors, 10 warnings)

Otherwise, the MR seems fine!

ciprian.jitaru’s picture

StatusFileSize
new9.83 KB

I've updated the patch from @Rob230 to work with Drupal 9.5.1

_utsavsharma’s picture

Status: Needs work » Needs review
_utsavsharma’s picture

StatusFileSize
new4.42 KB
new8.8 KB

Tried to fix CCF for #101.

Status: Needs review » Needs work

The last submitted patch, 103: 2858890-103.patch, failed testing. View results

nsciacca made their first commit to this issue’s fork.

I was getting errors that .once didn't exist so I updated to use core once and fixed some code formatting. For the 10.x branch

capysara made their first commit to this issue’s fork.

capysara’s picture

Rebased against the most recent 10.1.x codebase.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ckng’s picture

With patch #103, works after cleared cache. However, issue reappears after some time. Caching issue?

grevil’s picture

@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...

grevil’s picture

Unsure 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! 🙂

grevil’s picture

Status: Needs work » Needs review

@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

anybody’s picture

@Grevil: No, sadly no such option. Can only be done manually or by patch, sorry.

grevil’s picture

grevil’s picture

Alright! 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!

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The 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.

grevil’s picture

Status: Needs work » Needs review

How 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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

Can the issue summary be updated with steps to reproduce. Also the link is pointing to 8.4 so definitely outdated.

smustgrave’s picture

Also as a bug will need a test case.

grevil’s picture

OK, 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.

grevil’s picture

It 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".

grevil’s picture

Assigned: Unassigned » grevil

I'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.

grevil’s picture

Issue tags: +Needs tests

Let's see if tests succeed on that branch as well (1 failing test is expected, which needs to be refactored).

grevil’s picture

Alright! 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)

grevil’s picture

Version: 11.x-dev » 10.1.x-dev

grevil’s picture

Version: 10.1.x-dev » 11.x-dev
Assigned: grevil » Unassigned
Priority: Major » Normal

I 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.

grevil’s picture

Issue tags: +Needs manual testing

Update 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:

  • "2858890-2858890-views-ajax-fix-init-in-nested-views-patch-79-10.1.x" => for 10.1.x
  • "2858890-views-ajax-fix-init-in-nested-views-patch-79" for 11.x

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.

maximkashuba made their first commit to this issue’s fork.

maximkashuba’s picture

rebased 2858890-views-ajax-fix-init-in-nested-views-patch-79 branch from 10.1.x to make the changes applicable.

nsciacca’s picture

The 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')

nsciacca’s picture

I 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.

rob230’s picture

Merge 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.

arousseau made their first commit to this issue’s fork.

johnv’s picture

Title: Drupal.views.ajaxView is not initializing pagers in nested views » Pager is not initialized in nested views in Drupal.views.ajaxView

prudloff changed the visibility of the branch 2858890-10.2.x-views-ajax-fix-init-in-nested-views to hidden.

prudloff changed the visibility of the branch 2858890-2858890-views-ajax-fix-init-in-nested-views-patch-79-10.1.x to hidden.

prudloff’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
prudloff’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

It looks like patches used to have tests but they were dropped starting with comment 42.
I added them back.

smustgrave’s picture

left a small comment on the MR but leaving in review

smustgrave’s picture

Status: Needs review » Needs work

Since it's been 2 months left some comments on the MR around the tests.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.