Incorrect position of the suggestion drop-down
authorAlexander Ebert <ebert@woltlab.com>
Tue, 23 Mar 2021 18:16:23 +0000 (19:16 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 23 Mar 2021 18:16:23 +0000 (19:16 +0100)
Related issue: #4096

ts/WoltLabSuite/Core/Ui/Dropdown/Simple.ts
ts/WoltLabSuite/Core/Ui/Search/Input.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js

index 475f6761868891d5bb5c8843594955a933671211..729272902f7b73dc3115b1c97bee799e7220910b 100644 (file)
@@ -566,10 +566,10 @@ const UiDropdownSimple = {
   /**
    * Opens the dropdown unless it is already open.
    */
-  open(containerId: string, disableAutoFocus?: boolean): void {
+  open(containerId: string, disableAutoFocus?: boolean, referenceElement?: HTMLElement): void {
     const menu = _menus.get(containerId);
     if (menu !== undefined && !menu.classList.contains("dropdownOpen")) {
-      UiDropdownSimple.toggleDropdown(containerId, undefined, disableAutoFocus);
+      UiDropdownSimple.toggleDropdown(containerId, referenceElement, disableAutoFocus);
     }
   },
 
index 934ef2fe81b5ad265d5b6c581d9a8baf6d189a79..39ffd5fd7cf05225cab0423e94617f74a07e08b3 100644 (file)
@@ -288,10 +288,8 @@ class UiSearchInput {
 
     if (typeof data.returnValues === "object") {
       const callbackClick = this.clickSelectItem.bind(this);
-      let listItem;
-
       Object.keys(data.returnValues).forEach((key) => {
-        listItem = this.createListItem(data.returnValues[key]);
+        const listItem = this.createListItem(data.returnValues[key]);
 
         listItem.addEventListener("click", callbackClick);
         this.list!.appendChild(listItem);
@@ -312,7 +310,7 @@ class UiSearchInput {
       if (!this.list.childElementCount && !this.handleEmptyResult()) {
         UiDropdownSimple.close(this.dropdownContainerId);
       } else {
-        UiDropdownSimple.open(this.dropdownContainerId, true);
+        UiDropdownSimple.open(this.dropdownContainerId, true, this.element);
 
         // mark first item as active
         const firstChild = this.list.childElementCount ? (this.list.children[0] as HTMLLIElement) : undefined;
index d1eda1748bab260059da1d1362f4720bb82065f5..b2c0a48c92670d61d33f4b0da2f11d52031605f0 100644 (file)
@@ -472,10 +472,10 @@ define(["require", "exports", "tslib", "../../CallbackList", "../../Core", "../.
         /**
          * Opens the dropdown unless it is already open.
          */
-        open(containerId, disableAutoFocus) {
+        open(containerId, disableAutoFocus, referenceElement) {
             const menu = _menus.get(containerId);
             if (menu !== undefined && !menu.classList.contains("dropdownOpen")) {
-                UiDropdownSimple.toggleDropdown(containerId, undefined, disableAutoFocus);
+                UiDropdownSimple.toggleDropdown(containerId, referenceElement, disableAutoFocus);
             }
         },
         /**
index e81886d67f58cd1f2d6c13cc8025ef5b9a524933..4f69b3391eace1e0d3f2661f239350d6c58d5680 100644 (file)
@@ -242,9 +242,8 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut
             }
             if (typeof data.returnValues === "object") {
                 const callbackClick = this.clickSelectItem.bind(this);
-                let listItem;
                 Object.keys(data.returnValues).forEach((key) => {
-                    listItem = this.createListItem(data.returnValues[key]);
+                    const listItem = this.createListItem(data.returnValues[key]);
                     listItem.addEventListener("click", callbackClick);
                     this.list.appendChild(listItem);
                 });
@@ -261,7 +260,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut
                     Simple_1.default.close(this.dropdownContainerId);
                 }
                 else {
-                    Simple_1.default.open(this.dropdownContainerId, true);
+                    Simple_1.default.open(this.dropdownContainerId, true, this.element);
                     // mark first item as active
                     const firstChild = this.list.childElementCount ? this.list.children[0] : undefined;
                     if (this.autoFocus && firstChild && ~~(firstChild.dataset.objectId || "")) {