Skip to content

✨ Add "Keep Open" option for menu items#1336

Open
manuxdev wants to merge 5 commits intokando-menu:mainfrom
manuxdev:feature/keep-open-menu-items
Open

✨ Add "Keep Open" option for menu items#1336
manuxdev wants to merge 5 commits intokando-menu:mainfrom
manuxdev:feature/keep-open-menu-items

Conversation

@manuxdev
Copy link
Copy Markdown

@manuxdev manuxdev commented Apr 7, 2026

This PR adds a keepOpen boolean property to menu items that allows the
menu to stay open after an item is selected. This is useful for actions
that users want to execute repeatedly without having to reopen the menu
each time (e.g. volume control, media playback, etc.).

Changes

  • Schema: Added keepOpen: boolean field to MENU_ITEM_SCHEMA_V1
  • Menu renderer: When a keepOpen item is selected, the menu resets
    to its previous interactive state instead of closing
  • Main process: Skips hideWindow() and delayed execution for
    keepOpen items, executing the action immediately instead
  • Settings UI: Added a "Keep menu open" checkbox in the item
    properties panel (shown for all non-submenu item types)
  • Translations: Added keep-open and keep-open-info keys to
    locales/en/translation.json
  • Bugfixes: Added missing events polyfill for webpack 5 renderer
    bundle, and added fs-extra as explicit dev dependency (required for
    pnpm strict isolation)

How it works

  1. User enables "Keep menu open" checkbox in the item's properties
  2. When the item is selected, the renderer emits the select event with
    keepOpen=true
  3. The renderer calls resetLeafSelection() instead of hiding the menu,
    restoring the menu to its pre-selection state
  4. The main process executes the action without calling hideWindow()

Testing

  • Add any action item (hotkey, command, URI, etc.)
  • Enable "Keep menu open" in its properties
  • Open the menu and click the item — the menu should stay open
  • The action should execute and the item should be selectable again

manuxdev added 4 commits April 7, 2026 14:24
webpack 5 no longer polyfills Node.js built-ins like 'events' by default.
Added resolve.fallback for the 'events' module so the renderer bundle
can use EventEmitter in browser context.

Also added fs-extra and @types/fs-extra as explicit devDependencies since
the package was already used in src/main/ but only available as a transitive
dependency, which causes issues with strict package managers like pnpm.
Adds a new 'keepOpen' boolean property to menu items that prevents the
menu from closing after the item's action is executed. This allows users
to trigger the same action repeatedly (e.g. volume up/down, undo/redo,
media controls) without having to reopen the menu each time.

Changes:
- Added 'keepOpen' field to MENU_ITEM_SCHEMA_V1
- Added 'resetLeafSelection()' public method to Menu class to restore
  the menu to its interactive state without closing it
- Saved and restored root position on reset to prevent visual shift
- Skipped hideWindow() in the main process for keepOpen items
- Added 'Keep menu open' checkbox in the item properties panel
  (visible for all non-root, non-submenu item types)
- Added English translations for the new option
On macOS, CGEventPost sends simulated keys to the frontmost app. Since
the Kando window is active while the menu is open, hotkey/macro actions
executed via keepOpen would be consumed by Kando itself instead of the
target application.

Fix: before executing a keepOpen action on macOS, activate the previous
app (via `open -b <bundleId>`) so simulated keys reach the right target.
After execution, refocus the Kando window to keep the menu interactive.
- On macOS, activate the previous app before executing keepOpen hotkey/macro
  actions so simulated keys reach the target app instead of Kando
- Add try/finally in simulateKeys() to ensure shortcut inhibition is always
  released even if key simulation fails (e.g. missing accessibility permissions)
@manuxdev manuxdev force-pushed the feature/keep-open-menu-items branch from 9028ae6 to c6ae8e4 Compare April 8, 2026 19:45
@Schneegans
Copy link
Copy Markdown
Contributor

Hey there! Thanks a ton for looking into this. It works quite well! Yet I'm not sure if this is the best solution to this problem. I think it would be better if the user could somehow decide whether the menu should stay open after a selection. With this new option turned on, it is pretty awkward if you want to execute the action only once.

I think it's a valid use case that a user may want to keep the menu open sometimes but not every time. Have you looked into #1190? I think that maybe using middle-mouse click instead of this option could be a good approach. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants