Skip to content

Commit e8f186f

Browse files
authored
Merge pull request #171 from sbondCo/search-issue
Nav: Fix search input not re-focusing after search loads on chromium
2 parents faff9ff + d0a9647 commit e8f186f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: src/routes/(app)/+layout.svelte

+8-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@
5959
const query = target?.value.trim();
6060
if (!query) return;
6161
if (query) {
62+
// Enable autofocus before running `goto` because on chromium
63+
// the .focus() call won't work, even after a timeout.
64+
// Using autofocus seems to work. Disables after goto runs.
65+
// https://github.com/sbondCo/Watcharr/issues/169
66+
target.autofocus = true;
6267
goto(`/search/${query}`).then(() => {
6368
target?.focus();
69+
target.autofocus = false;
6470
});
6571
}
6672
},
@@ -171,9 +177,9 @@
171177
let scroll = window.scrollY;
172178
window.document.addEventListener("scroll", (ev: Event) => {
173179
if (scroll > window.scrollY) {
174-
navEl.classList.remove("scrolled-down");
180+
navEl?.classList.remove("scrolled-down");
175181
} else {
176-
navEl.classList.add("scrolled-down");
182+
navEl?.classList.add("scrolled-down");
177183
subMenuShown = false;
178184
filterMenuShown = false;
179185
sortMenuShown = false;

0 commit comments

Comments
 (0)