Skip to content

fix: keyboard shortcuts not working after clicking a node from an unfocused window#10

Open
DisciplinedSoftware wants to merge 2 commits intoOlegIGalkin:mainfrom
DisciplinedSoftware:feature/fix-keyboard-after-click-without-focus
Open

fix: keyboard shortcuts not working after clicking a node from an unfocused window#10
DisciplinedSoftware wants to merge 2 commits intoOlegIGalkin:mainfrom
DisciplinedSoftware:feature/fix-keyboard-after-click-without-focus

Conversation

@DisciplinedSoftware
Copy link

Problem

Clicking on a node when the editor window does not have focus sets the selection, but subsequent keyboard shortcuts (e.g. Delete, Backspace, Tab, arrow keys) are silently ignored. Clicking the node a second time makes them work.

Root Cause

The selectNode function sets this.currentNode but never calls this.map.focus(). The map's keydown handler only fires when the map element has DOM focus. On the first click from an unfocused window the OS delivers the click but keyboard focus is not transferred to the map element, so all key presses are lost. A second click (with the window already active) works because the map is already focused.

Fix

1 – selectNode now focuses the map (both extensions)

Added this.map.focus() right after this.currentNode = e in the selectNode function inside MindElixir.js:

  • VS Code/MindElixir/MindElixir.js
  • Visual Studio/CodeMindMap/MindElixir/MindElixir.js

2 – Dev webpack config now copies MindElixir.js to out/ (VS Code extension)

webpack.dev.config.js was missing CopyWebpackPlugin, so running bundle-dev / watch never produced out/MindElixir/MindElixir.js. The webview couldn't load the library at all in development builds, causing a blank diagram. Added the same CopyWebpackPlugin pattern that already existed in the production config.

The Visual Studio extension includes MindElixir.js as a direct Content file in the .csproj, so no equivalent build-config change is needed there.

Pierre-Luc Gagné and others added 2 commits March 2, 2026 01:32
…irst click

When the window did not have focus, clicking a node set currentNode but
did not focus the map element. Subsequent key presses (e.g. Delete) were
therefore ignored by the map's keydown handler. Adding this.map.focus()
inside selectNode ensures the map is always focused after selecting a
node, making keyboard shortcuts work immediately after the first click.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…copied to out/

Without this, running bundle-dev or watch did not produce out/MindElixir/MindElixir.js,
causing the webview to fail to load the diagram.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 2, 2026 06:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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