Skip to content

Commit

Permalink
Merge pull request #171 from sbondCo/search-issue
Browse files Browse the repository at this point in the history
Nav: Fix search input not re-focusing after search loads on chromium
  • Loading branch information
IRHM authored Oct 27, 2023
2 parents faff9ff + d0a9647 commit e8f186f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@
const query = target?.value.trim();
if (!query) return;
if (query) {
// Enable autofocus before running `goto` because on chromium
// the .focus() call won't work, even after a timeout.
// Using autofocus seems to work. Disables after goto runs.
// https://github.com/sbondCo/Watcharr/issues/169
target.autofocus = true;
goto(`/search/${query}`).then(() => {
target?.focus();
target.autofocus = false;
});
}
},
Expand Down Expand Up @@ -171,9 +177,9 @@
let scroll = window.scrollY;
window.document.addEventListener("scroll", (ev: Event) => {
if (scroll > window.scrollY) {
navEl.classList.remove("scrolled-down");
navEl?.classList.remove("scrolled-down");
} else {
navEl.classList.add("scrolled-down");
navEl?.classList.add("scrolled-down");
subMenuShown = false;
filterMenuShown = false;
sortMenuShown = false;
Expand Down

0 comments on commit e8f186f

Please sign in to comment.