Browse Source

fix: make old menu interact with inert-ness rules of new dialog class

Sv443 11 months ago
parent
commit
7e6aca2930
2 changed files with 12 additions and 3 deletions
  1. 5 2
      src/components/BytmDialog.ts
  2. 7 1
      src/menu/menu_old.ts

+ 5 - 2
src/components/BytmDialog.ts

@@ -32,10 +32,13 @@ export interface BytmDialogOptions {
   renderFooter?: () => HTMLElement | Promise<HTMLElement>;
 }
 
+// TODO: remove export as soon as config menu is migrated to use BytmDialog
 /** ID of the last opened (top-most) dialog */
-let currentDialogId: string | null = null;
+export let currentDialogId: string | null = null;
 /** IDs of all currently open dialogs, top-most first */
-const openDialogs: string[] = [];
+export const openDialogs: string[] = [];
+/** TODO: remove as soon as config menu is migrated to use BytmDialog */
+export const setCurrentDialogId = (id: string | null) => currentDialogId = id;
 
 /** Creates and manages a modal dialog element */
 export class BytmDialog extends NanoEmitter<{

+ 7 - 1
src/menu/menu_old.ts

@@ -7,7 +7,7 @@ import { siteEvents } from "../siteEvents";
 import { getChangelogDialog, getExportDialog, getFeatHelpDialog, getImportDialog } from "../dialogs";
 import type { FeatureCategory, FeatureKey, FeatureConfig, HotkeyObj, FeatureInfo } from "../types";
 import "./menu_old.css";
-import { createHotkeyInput, createToggleInput } from "../components";
+import { createHotkeyInput, createToggleInput, openDialogs, setCurrentDialogId } from "../components";
 import pkg from "../../package.json" assert { type: "json" };
 
 //#region create menu
@@ -804,6 +804,9 @@ export function closeCfgMenu(evt?: MouseEvent | KeyboardEvent, enableScroll = tr
 
   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 */
@@ -824,6 +827,9 @@ export async function openCfgMenu() {
   menuBg.style.visibility = "visible";
   menuBg.style.display = "block";
 
+  setCurrentDialogId("cfg-menu");
+  openDialogs.unshift("cfg-menu");
+
   checkToggleScrollIndicator();
 }