From 32bc631648a5690f84c5a15feb04da1a374e71d2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Dec 2022 00:16:06 +0200 Subject: [PATCH] autofocus gif search too --- files/assets/js/gif_modal.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index 2cc25dee9..a07421769 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -4,13 +4,15 @@ function commentForm(form) { commentFormID = form; }; +const gifSearchBar = document.getElementById('gifSearch') + async function getGif(searchTerm) { if (searchTerm !== undefined) { - document.getElementById('gifSearch').value = searchTerm; + gifSearchBar.value = searchTerm; } else { - document.getElementById('gifSearch').value = null; + gifSearchBar.value = null; } const loadGIFs = document.getElementById('gifs-load-more'); @@ -80,3 +82,10 @@ function insertGIF(url,form) { if (typeof checkForRequired === "function") checkForRequired(); } + +document.getElementById('gifModal').addEventListener('shown.bs.modal', function () { + gifSearchBar.focus(); + setTimeout(() => { + gifSearchBar.focus(); + }, 200); +});