فهرست منبع

fix: make number and arrow keys usable in cfg menu

Sv443 10 ماه پیش
والد
کامیت
6d56312bdd
2فایلهای تغییر یافته به همراه8 افزوده شده و 9 حذف شده
  1. 0 3
      src/features/input.ts
  2. 8 6
      src/menu/menu_old.ts

+ 0 - 3
src/features/input.ts

@@ -1,7 +1,6 @@
 import { DataStore, clamp, compress, decompress } from "@sv443-network/userutils";
 import { error, getVideoTime, info, log, warn, getVideoSelector, getDomain, compressionSupported, t, clearNode, resourceToHTMLString, getCurrentChannelId, currentMediaType } from "../utils/index.js";
 import type { Domain } from "../types.js";
-import { isCfgMenuOpen } from "../menu/menu_old.js";
 import { disableBeforeUnload } from "./behavior.js";
 import { siteEvents } from "../siteEvents.js";
 import { featInfo } from "./index.js";
@@ -129,8 +128,6 @@ export async function initNumKeysSkip() {
       return;
     if(!e.key.trim().match(/^[0-9]$/))
       return;
-    if(isCfgMenuOpen)
-      return;
     // discard the event when an unexpected element is currently active or in focus, like when editing a playlist or when the search bar is focused
     const ignoreElement = numKeysIgnoreTagNames.includes(document.activeElement?.tagName ?? "");
     if((document.activeElement !== document.body && ignoreElement) || ignoreElement)

+ 8 - 6
src/menu/menu_old.ts

@@ -2,7 +2,7 @@ import { debounce, isScrollable, type Stringifiable } from "@sv443-network/useru
 import { defaultData, getFeature, getFeatures, setFeatures } from "../config.js";
 import { buildNumber, host, mode, scriptInfo } from "../constants.js";
 import { featInfo, disableBeforeUnload } from "../features/index.js";
-import { error, getResourceUrl, info, log, resourceToHTMLString, getLocale, hasKey, initTranslations, setLocale, t, arrayWithSeparators, tp, type TrKey, onInteraction, getDomain, copyToClipboard } from "../utils/index.js";
+import { error, getResourceUrl, info, log, resourceToHTMLString, getLocale, hasKey, initTranslations, setLocale, t, arrayWithSeparators, tp, type TrKey, onInteraction, getDomain, copyToClipboard, warn } from "../utils/index.js";
 import { siteEvents } from "../siteEvents.js";
 import { getChangelogDialog, getExportDialog, getFeatHelpDialog, getImportDialog } from "../dialogs/index.js";
 import type { FeatureCategory, FeatureKey, FeatureConfig, HotkeyObj, FeatureInfo } from "../types.js";
@@ -779,6 +779,7 @@ export function closeCfgMenu(evt?: MouseEvent | KeyboardEvent, enableScroll = tr
   if(!isCfgMenuOpen)
     return;
   isCfgMenuOpen = false;
+
   evt?.bubbles && evt.stopPropagation();
 
   if(enableScroll) {
@@ -787,19 +788,20 @@ export function closeCfgMenu(evt?: MouseEvent | KeyboardEvent, enableScroll = tr
   }
   const menuBg = document.querySelector<HTMLElement>("#bytm-cfg-menu-bg");
 
+  clearTimeout(hiddenCopiedTxtTimeout);
+
+  openDialogs.splice(openDialogs.indexOf("cfg-menu"), 1);
+  setCurrentDialogId(openDialogs?.[0] ?? null);
+
   siteEvents.emit("cfgMenuClosed");
 
   if(!menuBg)
-    return;
+    return warn("Couldn't close config menu because background element couldn't be found. The config menu is considered closed but might still be open. In this case please reload the page. If the issue persists, please create an issue on GitHub.");
 
   menuBg.querySelectorAll<HTMLElement>(".bytm-ftconf-adv-copy-hint")?.forEach((el) => el.style.display = "none");
-  clearTimeout(hiddenCopiedTxtTimeout);
 
   menuBg.style.visibility = "hidden";
   menuBg.style.display = "none";
-
-  openDialogs.splice(openDialogs.indexOf("cfg-menu"), 1);
-  setCurrentDialogId(openDialogs?.[0] ?? null);
 }
 
 /** Opens the config menu if it is closed */