static: fix search redirecting entire page
This commit is contained in:
parent
f3010726d6
commit
4bd433d69e
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,3 @@
|
|||
// Search clearing
|
||||
document.querySelectorAll("input[type=search]").forEach((si) => {
|
||||
si.addEventListener("search", (e) => {
|
||||
if (si.value === "") {
|
||||
si.parentElement.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Fetch from data-attributes
|
||||
document.querySelectorAll("[data-pb-fetch-fill]").forEach((el) => {
|
||||
const url = el.dataset.pbFetchFill;
|
||||
|
|
|
@ -82,6 +82,17 @@ export class AdminSiteShell extends LitElement {
|
|||
this.loadContent();
|
||||
});
|
||||
});
|
||||
// Make get forms (search bar) notify us on submit so we can change the hash
|
||||
this.querySelectorAll("form").forEach((f) => {
|
||||
f.addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(f);
|
||||
const qs = new URLSearchParams(
|
||||
<any>(<unknown>formData)
|
||||
).toString();
|
||||
window.location.hash = `#${url}?${qs}`;
|
||||
});
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.loading = false;
|
||||
}, 100);
|
||||
|
|
Reference in New Issue