Views viewsScrollTop (ScrollTopCommand AJAX command) doesn't work inside Drupal Off canvas dialogs

Created on 28 July 2022, over 2 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

When we use ScrollTopCommand AJAX command for elements inside Drupal Off canvas dialogs - the function Drupal.AjaxCommands.prototype.viewsScrollTop doesn't work well when the main page is scrolled down, because it fails to calculate the right scroll position inside fixed elements.

Steps to reproduce

1. Open some Views in Drupal Off canvas area, that has enable AJAX and Pagination.
This Views should have long content to make a vertical scroll in the area.

2. Try to use pagination.

As result you will always be scrolled to the top of the page, instead to the right position, like in full page.

Proposed resolution

The problem is because Drupal Off canvas area has fixed position, so we should get the actual coordinates of it and current scroll position, to calculate the needed scroll position in the right way.

So now we have:

      $(scrollTarget).animate({ scrollTop: offset.top - 10 }, 500);

but it should be something like this:

      const scrollOffset =
        offset.top
        - scrollTarget.offset().top
        + $(scrollTarget).scrollTop();
      $(scrollTarget).animate({ scrollTop: scrollOffset - 10 }, 500);

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

10.1

Component
Ajax 

Last updated about 9 hours ago

Created by

🇦🇲Armenia murz Yerevan, Armenia

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024