Problem/Motivation

Drupal Views module has a very useful AJAX command ScrollTopCommand that allows to do a scroll in AJAX callbacks.

This function seems to be already used in many contrib modules: http://grep.xnddx.ru/search?text=ScrollTopCommand

And it looks pretty universal, without any direct dependency on Views.

So maybe move it from Views module to Drupal Core AJAX API? And we can keep a "Proxy" function in the Views Libraries to not break the old code, that already including it from the Views module.

Proposed resolution

Move scrollTop command from core/modules/views/js/ajax_view.js to core/misc/ajax.js with keeping the function as a proxy to call core's one (to backward compatibility).

Move core/modules/views/src/Ajax/ScrollTopCommand.php to core/lib/Drupal/Core/Ajax/ScrollTopCommand.php with keeping the function as a proxy to call core's one (for backward compatibility).

Remaining tasks

Review

User interface changes

None.

API changes

The function can be used as previously, but now it not requires the Views module, and can work from the Core directly.

Data model changes

None.

Release notes snippet

JS AJAX command scrollTop is moved from views/js/ajax_view.js to core/misc/ajax.js with keeping the function as a proxy on old place for backward compatibility.

CommentFileSizeAuthor
#18 3300481-nr-bot.txt2.66 KBneeds-review-queue-bot

Issue fork drupal-3300481

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

Murz created an issue. See original summary.

murz’s picture

Issue summary: View changes
murz’s picture

murz’s picture

Status: Active » Needs review

I have moved the PHP and JS function to the Drupal Core, and keep the "proxy" files to not break backward dependencies. I hope it should keep compatibility with old contrib code. Please review.

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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge require as a guide.

At this time we will need a 10.1.x MR of this issue. Would recommend starting a new one and closing this one out as jumping from 9.5.x to 10.1.x has been a nightmare for me.

murz’s picture

Status: Needs work » Needs review

I've rebased the changes on 10.1.x branch - please review.

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work

I apologize I should of added in #7 but can you update the issue summary for the proposed solution.

Reviewing the code I left 1 comment but since it's generic not sure what the standard is there. Know with new functions in D10 they would like them typehinted.

Everything else looks good to me.

murz’s picture

Issue summary: View changes
Status: Needs work » Needs review

I've fixed up the code by the last remark, and have updated the issue summary.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Open threads were resolved.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Left some comments on the MR.

smustgrave’s picture

Status: Needs review » Needs work

Moving to NW to address the comments in MR.

murz’s picture

Status: Needs work » Needs review

Thanks, I've fixed all by remarks, also have added a change record: https://www.drupal.org/node/3344141 - please review.

smustgrave’s picture

Seems to have a CI failure

needs-review-queue-bot’s picture

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

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

murz’s picture

Status: Needs work » Needs review

Fixed code style errors.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems all points have been resolved. Lets see what the committers think.

  • lauriii committed 5030f45e on 10.1.x
    Issue #3300481 by Murz, smustgrave, catch: Move ScrollTopCommand views...

lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5030f45 and pushed to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.