mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Force focus
This commit is contained in:
@@ -8,6 +8,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
function keepInputFocused() {
|
||||
if (document.activeElement !== searchInput) {
|
||||
searchInput.focus({ preventScroll: true });
|
||||
searchInput.select();
|
||||
}
|
||||
}
|
||||
|
||||
let channels = [];
|
||||
|
||||
function updateSuggestions(term) {
|
||||
@@ -38,6 +45,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
|
||||
searchInput.addEventListener("input", (event) => updateSuggestions(event.target.value || ""));
|
||||
searchInput.addEventListener("blur", () => {
|
||||
requestAnimationFrame(keepInputFocused);
|
||||
});
|
||||
|
||||
searchForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
@@ -49,5 +59,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
window.location.href = `/view/${encodeURIComponent(broadcaster)}/broadcast`;
|
||||
});
|
||||
|
||||
keepInputFocused();
|
||||
window.addEventListener("focus", keepInputFocused);
|
||||
loadChannels();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user