From f72cc613d9183e6f5017d6c499f22c53d5010e55 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Fri, 20 Dec 2024 20:58:54 +0100 Subject: [PATCH] fixed default selection being continously selected Whenever you'd use your mouse after a navigation function had been used, it'd just continuously re-select the default selection, unless you spam click, obviously not great. --- src/app/js/navigate.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/app/js/navigate.js b/src/app/js/navigate.js index f739aad..8cf2584 100644 --- a/src/app/js/navigate.js +++ b/src/app/js/navigate.js @@ -2,7 +2,9 @@ const events = require("./events"); const popups = require("./popups"); const settings = require("./settings"); -let navigate = {}; +let navigate = { + using: false +} // sets `#selection` to the correct position, size and border radius, // according to what is currently the `.active-selection`, if none is @@ -117,6 +119,9 @@ window.addEventListener("click", (e) => { return; } + // we're no longer using navigation functions + navigate.using = false; + // get the `.active-selection` let active_el = document.querySelector(".active-selection"); @@ -237,6 +242,13 @@ navigate.get_els = (div) => { // if not inside a popup we'll just use the currently selected tab in // the `.gamesContainer` sidebar navigate.default_selection = () => { + // if we're not currently using any navigation functions, this + // function shouldn't do anything, as it'll cause a selection to be + // made, when it shouldn't be + if (! navigate.using) { + return; + } + // the spread operator is to convert from a `NodeList` to an // `Array`, and then we need to reverse this to get the ones // that are layered on top first. @@ -292,6 +304,9 @@ navigate.default_selection = () => { // this navigates `#selection` in the direction of `direction` // this can be: up, down, left and right navigate.move = async (direction) => { + // make sure we note down that we're using navigation functions + navigate.using = true; + // get the `.active-selection` if there is one let active = document.querySelector(".active-selection"); @@ -471,6 +486,9 @@ navigate.move = async (direction) => { // selects the currently selected element, by clicking or focusing it navigate.select = () => { + // make sure we note down that we're using navigation functions + navigate.using = true; + // get the current selection let active = document.querySelector(".active-selection");