Fix the jump to the option being searched for
authorAlexander Ebert <ebert@woltlab.com>
Fri, 28 Jul 2023 12:49:38 +0000 (14:49 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 28 Jul 2023 12:49:38 +0000 (14:49 +0200)
Fixes #5580

wcfsetup/install/files/acp/templates/option.tpl

index 9305aa4c1ee24de2bb64db915507f77ee3457cc3..1e68a60f3613dc2feda0531e12529417ad3e80f9 100644 (file)
@@ -12,7 +12,7 @@
                const optionName = searchParams.get("optionName");
                if (optionName) {
                        window.setTimeout(() => {
-                               const element = document.getElementById(optionName);
+                               const element = document.querySelector(`#${ optionName }, label[for="${ optionName }"]`);
                                if (!element) {
                                        return;
                                }
 
                                const elementTop = Math.trunc(element.getBoundingClientRect().top);
                                window.scrollTo(0, elementTop - 50);
-                               element.focus();
+
+                               try {
+                                       element.focus();
+                               } catch {}
                                
                                window.setTimeout(() => {
                                        const label = dl.querySelector("dt label");
                                        label.classList.add("hightlightOptionLabel");
                                        label.addEventListener("transitionEnd",() => label.classList.remove("hightlightOptionLabel"), { once: true });
                                }, 500);
-                       }, 200);
+                       }, 1_000);
                }
        });