From 76bc6ae965eb3c7513a76363868246fc7d68ebe3 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 13:58:06 +0200 Subject: [PATCH] #12 Reset quick search after usage --- enhancements/quickSearch.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/enhancements/quickSearch.js b/enhancements/quickSearch.js index 1bf32ba..212e7aa 100644 --- a/enhancements/quickSearch.js +++ b/enhancements/quickSearch.js @@ -37,13 +37,19 @@ function initSearch() { function handleQuickSearch(event) { if (event.key === 'Enter') { + let quickSearchElement = document.getElementById(quickSearchID); + let linkElement = document.getElementById(quickSearchLink); + let url = new URL(window.location.origin) url.pathname = '/search'; - url.searchParams.append('q', document.getElementById(quickSearchID).value); + url.searchParams.append('q', quickSearchElement.value); - let linkElement = document.getElementById(quickSearchLink); linkElement.href = `${url.pathname}${url.search}`; linkElement.click(); + + // clean up afterwards + linkElement.href = ''; + quickSearchElement.value = ''; } }