Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nav: Fix search input not re-focusing after search loads on chromium #171

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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