aboutsummaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-05-04 03:56:38 -0400
committertdro <tdro@noreply.example.com>2022-05-04 03:56:38 -0400
commitd4570297d931c001b3a95ba3ab5f3891fd8a99f9 (patch)
tree9645db81f8e4b83e83457b62ea9cc480601a6710 /static/js
parent8200cb6919489187b2916fc8902f75eb4293d1a2 (diff)
downloadcanory-d4570297d931c001b3a95ba3ab5f3891fd8a99f9.tar.gz
canory-d4570297d931c001b3a95ba3ab5f3891fd8a99f9.tar.bz2
canory-d4570297d931c001b3a95ba3ab5f3891fd8a99f9.zip
static/js/fixedsearch: Keep search bar focused on inactivity
Diffstat (limited to 'static/js')
-rw-r--r--static/js/fixedsearch.ts4
-rw-r--r--static/js/index.js4
2 files changed, 8 insertions, 0 deletions
diff --git a/static/js/fixedsearch.ts b/static/js/fixedsearch.ts
index 26b9ac1..3788cb3 100644
--- a/static/js/fixedsearch.ts
+++ b/static/js/fixedsearch.ts
@@ -9,6 +9,7 @@
const query = document.getElementById("search-input"); // input box for search
const submit = document.getElementById("search-submit"); // form submit button
const dropdown = document.getElementById("search-results"); // targets the <ul>
+ const container = document.getElementById("search-frame"); // targets the upper parent container
form.addEventListener("focusin", function () {
initialize();
@@ -79,6 +80,7 @@
scrolls = 0;
document.activeElement.blur();
dropdown.setAttribute("hidden", "");
+ container.removeAttribute("data-focus");
}
scrolls++;
});
@@ -86,6 +88,7 @@
document.addEventListener("click", function (event) {
if (!form.contains(event.target)) {
dropdown.setAttribute("hidden", "");
+ container.removeAttribute("data-focus");
}
});
@@ -163,6 +166,7 @@
</li>
`;
dropdown.removeAttribute("hidden");
+ container.setAttribute("data-focus", "");
} else {
dropdown.removeAttribute("hidden");
for (const string in results.slice(0, 10)) {
diff --git a/static/js/index.js b/static/js/index.js
index df649df..8c6e922 100644
--- a/static/js/index.js
+++ b/static/js/index.js
@@ -279,6 +279,7 @@
const query = document.getElementById("search-input");
document.getElementById("search-submit");
const dropdown = document.getElementById("search-results");
+ const container = document.getElementById("search-frame");
form.addEventListener("focusin", function() {
initialize();
});
@@ -331,12 +332,14 @@
scrolls = 0;
document.activeElement.blur();
dropdown.setAttribute("hidden", "");
+ container.removeAttribute("data-focus");
}
scrolls++;
});
document.addEventListener("click", function(event) {
if (!form.contains(event.target)) {
dropdown.setAttribute("hidden", "");
+ container.removeAttribute("data-focus");
}
});
function fetch_JSON(path, callback) {
@@ -401,6 +404,7 @@
</li>
`;
dropdown.removeAttribute("hidden");
+ container.setAttribute("data-focus", "");
} else {
dropdown.removeAttribute("hidden");
for(const string in results.slice(0, 10)){