Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(electron): zoom in with Ctrl+= on Windows and Linux

Bugfixer 236bd43fcbf3f
diff --git a/electron/menu.mjs b/electron/menu.mjs
index 79438a1614..7c8fdd72cb 100644
--- a/electron/menu.mjs
+++ b/electron/menu.mjs
@@ -46,6 +46,8 @@ function roleMenus(t, isMac) {
{ type: "separator" },
role(t, "resetZoom", "native.role.actualSize"),
role(t, "zoomIn", "native.role.zoomIn"),
+ // Electron's Zoom In key is Ctrl+Plus (Ctrl+Shift+=), so the unshifted =/+ key needs its own hidden item off macOS.
+ ...(isMac ? [] : [{ ...role(t, "zoomIn", "native.role.zoomIn"), accelerator: "CommandOrControl+=", visible: false }]),
role(t, "zoomOut", "native.role.zoomOut"),
{ type: "separator" },
role(t, "togglefullscreen", "native.role.toggleFullScreen"),
diff --git a/electron/menu.test.mjs b/electron/menu.test.mjs
index df6420cd18..3664c69e0e 100644
--- a/electron/menu.test.mjs
+++ b/electron/menu.test.mjs
@@ -145,7 +145,7 @@ describe("buildApplicationMenu", () => {
},
};
ELECTRON_DEFAULTS.linux = ELECTRON_DEFAULTS.win32;
- const roles = (items) => items.map((item) => (item.type === "separator" ? "-" : item.submenu ? roles(item.submenu) : item.role));
+ const roles = (items) => items.filter((item) => item.visible !== false).map((item) => (item.type === "separator" ? "-" : item.submenu ? roles(item.submenu) : item.role));
const labelled = (items) => items.flatMap((item) => (item.type === "separator" ? [] : [item, ...(item.submenu ? labelled(item.submenu) : [])]));
it.each(["darwin", "win32", "linux"])("writes out Electron's own role menus on %s, each item with a label", (platform) => {
@@ -159,6 +159,13 @@ describe("buildApplicationMenu", () => {
expect(items.filter((item) => item.role).length).toBeGreaterThan(15);
});
+ it.each([["win32", true], ["linux", true], ["darwin", false]])("zooms in with Ctrl+= too on %s, without a second visible Zoom In", (platform, extra) => {
+ const view = build(platform).find((entry) => entry.role === "viewMenu").submenu;
+ const zoomIn = view.filter((entry) => entry.role === "zoomIn");
+ expect(zoomIn.filter((entry) => entry.visible !== false)).toEqual([{ role: "zoomIn", label: "Zoom In" }]);
+ expect(zoomIn.filter((entry) => entry.accelerator === "CommandOrControl+=")).toEqual(extra ? [{ role: "zoomIn", label: "Zoom In", accelerator: "CommandOrControl+=", visible: false }] : []);
+ });
+
it("keeps Electron's English labels for every role item in English", () => {
const english = { close: "Close Window", undo: "Undo", redo: "Redo", cut: "Cut", copy: "Copy", paste: "Paste", pasteAndMatchStyle: "Paste and Match Style",
delete: "Delete", selectAll: "Select All", showSubstitutions: "Show Substitutions", toggleSmartQuotes: "Smart Quotes", toggleSmartDashes: "Smart Dashes",