Page change in search results scrolls to top automatically
authorMarcel Werk <burntime@woltlab.com>
Sun, 1 May 2022 17:54:36 +0000 (19:54 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 1 May 2022 17:54:36 +0000 (19:54 +0200)
ts/WoltLabSuite/Core/Ui/Search/Extended.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Extended.js

index 0717a98cc2d8835ffeb757b0f2d1cbba8e806db5..51cdaac1c16324d2b7d3f3358ecdee1738d1cba5 100644 (file)
@@ -14,6 +14,7 @@ import * as DomUtil from "../../Dom/Util";
 import { ucfirst } from "../../StringUtil";
 import UiPagination from "../Pagination";
 import UiSearchInput from "./Input";
+import * as UiScroll from "./../Scroll";
 
 type ResponseSearch = {
   count: number;
@@ -173,7 +174,11 @@ export class UiSearchExtended {
       maxPage: this.pages,
 
       callbackSwitch: (pageNo) => {
-        void this.changePage(pageNo);
+        void this.changePage(pageNo).then(() => {
+          if (position === "bottom") {
+            UiScroll.element(this.form.nextElementSibling as HTMLElement, undefined, "auto");
+          }
+        });
       },
     });
   }
index d02a87738c7c6c5d42ddf7193a025fd7cff1703c..cdd4d0900d709a1d59a750e35562809e7d1953b6 100644 (file)
@@ -7,7 +7,7 @@
  * @module  WoltLabSuite/Core/Ui/Search/Extended
  * @woltlabExcludeBundle all
  */
-define(["require", "exports", "tslib", "../../Ajax", "../../Date/Picker", "../../Dom/Util", "../../StringUtil", "../Pagination", "./Input"], function (require, exports, tslib_1, Ajax_1, Picker_1, DomUtil, StringUtil_1, Pagination_1, Input_1) {
+define(["require", "exports", "tslib", "../../Ajax", "../../Date/Picker", "../../Dom/Util", "../../StringUtil", "../Pagination", "./Input", "./../Scroll"], function (require, exports, tslib_1, Ajax_1, Picker_1, DomUtil, StringUtil_1, Pagination_1, Input_1, UiScroll) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
     exports.UiSearchExtended = void 0;
@@ -15,6 +15,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Date/Picker", "../..
     DomUtil = tslib_1.__importStar(DomUtil);
     Pagination_1 = tslib_1.__importDefault(Pagination_1);
     Input_1 = tslib_1.__importDefault(Input_1);
+    UiScroll = tslib_1.__importStar(UiScroll);
     class UiSearchExtended {
         constructor() {
             this.pages = 0;
@@ -136,7 +137,11 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Date/Picker", "../..
                 activePage: this.activePage,
                 maxPage: this.pages,
                 callbackSwitch: (pageNo) => {
-                    void this.changePage(pageNo);
+                    void this.changePage(pageNo).then(() => {
+                        if (position === "bottom") {
+                            UiScroll.element(this.form.nextElementSibling, undefined, "auto");
+                        }
+                    });
                 },
             });
         }