diff options
Diffstat (limited to 'core/misc/ajax.js')
-rw-r--r-- | core/misc/ajax.js | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 252e0db24d1e..a9ce2cf3fcd0 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -1860,23 +1860,7 @@ * Selector to use. */ scrollTop(ajax, response) { - const offset = $(response.selector).offset(); - // We can't guarantee that the scrollable object should be - // the body, as the element could be embedded in something - // more complex such as a modal popup. Recurse up the DOM - // and scroll the first element that has a non-zero top. - let scrollTarget = response.selector; - while ($(scrollTarget).scrollTop() === 0 && $(scrollTarget).parent()) { - scrollTarget = $(scrollTarget).parent(); - } - - // Only scroll upward. - if (offset.top - 10 < $(scrollTarget).scrollTop()) { - scrollTarget.get(0).scrollTo({ - top: offset.top - 10, - behavior: 'smooth', - }); - } + document.querySelector(response.selector)?.scrollIntoView(); }, }; |