From 80f32e615d75892b47ed954e39c79215fbcc6ef4 Mon Sep 17 00:00:00 2001 From: Eloc <42568538+elocremarc@users.noreply.github.com> Date: Wed, 6 Sep 2023 11:58:16 -0700 Subject: [PATCH] Prevent search when query field is empty (#2425) --- static/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/static/index.js b/static/index.js index 2c6632f9d4..e3153179b7 100644 --- a/static/index.js +++ b/static/index.js @@ -23,3 +23,12 @@ window.addEventListener('keydown', e => { return; } }); + +const search = document.querySelector('form[action="/search"]'); +const query = search.querySelector('input[name="query"]'); + +search.addEventListener('submit', (e) => { + if (!query.value) { + e.preventDefault(); + } +});