Fix Inconsistent Infinite Scrolling in Views with Improved JavaScript Handling

Created on 16 July 2024, 5 months ago

The views_infinite_scroll module has inconsistent behavior with infinite scrolling in Drupal views. Specifically:

  1. The infinite scrolling sometimes fails to work correctly, causing intermittent issues where content is not loaded as expected.
  2. The once parameter is missing in the infinite-scroll.js file, leading to duplicate execution of certain JavaScript behaviors.
  3. The views-infinite-scroll JavaScript library is not always attached correctly when AJAX is enabled, resulting in potential stability and functionality issues.

Steps to reproduce

  1. Set up a view with infinite scrolling using the views_infinite_scroll module.
  2. Enable AJAX for the view.
  3. Scroll through the content to observe that sometimes the infinite scroll fails to load more content.

Proposed resolution

  1. Modify the infinite-scroll.js file to include the once parameter, ensuring certain JavaScript behaviors are applied only once to each element.
  2. Adjust the views_infinite_scroll.module to attach the views-infinite-scroll JavaScript library only when AJAX is enabled on a view.

Remaining tasks

  1. Apply the patch to the infinite-scroll.js file to add the once parameter.
  2. Update the views_infinite_scroll.module to conditionally attach the views-infinite-scroll JavaScript library.
  3. Test the changes to confirm that infinite scrolling works consistently.
  4. Submit the patch for review and contribute it back to the community.

User interface changes

No direct user interface changes, but users will experience more reliable infinite scrolling in views.

API changes

No API changes.

Data model changes

No data model changes.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇨🇷Costa Rica yuvania

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @yuvania
  • 🇨🇷Costa Rica yuvania

    The patch improves the infinite-scroll.js file and the views_infinite_scroll.module to ensure that infinite scrolling works consistently. Changes include:

    Adding the once parameter to the JavaScript function to ensure certain behaviors are applied only once per element.
    Adjusting the module to attach the views-infinite-scroll library only when AJAX is enabled on a view.

Production build 0.71.5 2024