From 4bc3d7dcc1ec6206f61c8c9c82616e40ae3d27fc Mon Sep 17 00:00:00 2001 From: Jaidyn Levesque <10477760+JadedCtrl@users.noreply.github.com> Date: Sat, 26 Nov 2022 13:39:20 -0600 Subject: [PATCH] Use 'change' event for preset-list rather than 'click' This lets the user select events with their keyboard. --- popup/search.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/popup/search.js b/popup/search.js index 8da1394..cc1312e 100644 --- a/popup/search.js +++ b/popup/search.js @@ -114,6 +114,7 @@ const searchboxaspresetname = () => { let textbox = document.getElementById("searchbox"); textbox.setAttribute("placeholder", "New preset nameā€¦"); deselectengines(); + document.getElementById("searchbox").focus(); } const resetsearchbox = (clearText = false) => { @@ -146,7 +147,8 @@ const saveselection = () => { savepreset(engineselection(), name); } -const onpresetselected = (value) => { +const onpresetselected = (event) => { + let value = document.getElementById("presets").value; if (value != "newPreset") localStorage.setItem("defaultPreset", value); resetsearchbox(); @@ -157,8 +159,6 @@ const onpresetselected = (value) => { searchboxaspresetname(); else enablepresetbyname(value); - - document.getElementById("searchbox").focus(); } const removefromarray = (array, item) => { @@ -181,6 +181,11 @@ document.getElementById("searchbox").addEventListener("keypress", key => { if (event.key == "Enter") search(); }); +document.addEventListener("change", e => { + if (e.target.id == "presets") + onpresetselected(); +}) + document.addEventListener("click", e => { if (e.target.classList.contains("search")) search(); @@ -188,7 +193,4 @@ document.addEventListener("click", e => { saveselection(); else if (e.target.classList.contains("remove")) removecurrentpreset(); - else if (e.target.tagName == "OPTION") { - onpresetselected(e.target.getAttribute("value")); - } });