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