- Issue created by @mrshowerman
- 🇩🇪Germany mrshowerman Munich
Attaching patch that removes the DOM traversal and replaces scollTo() with scrollIntoView().
This is just a proof of concept and a base for discussion, thus no MR at this point. - 🇺🇸United States smustgrave
Issue summary appears incomplete.
Fixes should also be in an MR, may help determine if it will need test coverage.
- First commit to issue fork.
- 🇩🇪Germany mrshowerman Munich
@mrinalini9, thanks for the MR.
Had a go at the issue summary. Not sure if we need a release note snippet, thus leaving in NW state. - 🇮🇳India mdsohaib4242
Using scrollIntoView() could be a better option here, especially if you have fixed headers or other elements that might obscure the view. It allows you to specify options for more control, like:
element.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' });
Your CSS can define the scroll offset like you mentioned:
[data-once="ajax-pager"] { scroll-margin-top: 5rem; }
That JavaScript block recursing up the DOM to find the scrollable object seems to be a workaround that might no longer be necessary with scrollIntoView()
The Needs Review Queue Bot → tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily 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.
- Status changed to RTBC
about 1 month ago 2:13pm 6 June 2025 - 🇦🇲Armenia murz Yerevan, Armenia
Tested the fix in the MR and it works well.
Reviewed the changes and the solution is very simple, removes a lot of the legacy code, and makes the function clear.
About the hard-coded offset of 10px - the right solution is to use the CSS rule "scroll-margin-top: 10px" instead of hardcoding, so it's good that we're removing this.
As I see no issues with the new implementation, moving to the Reviewed and tested status.
- 🇫🇷France nod_ Lille
Committed and pushed e1c818c662f to 11.x and 03a3cf72cc4 to 10.6.x. Thanks!
Automatically closed - issue fixed for 2 weeks with no activity.