fix: keyboard shortcuts not working after clicking a node from an unfocused window#10
Open
DisciplinedSoftware wants to merge 2 commits intoOlegIGalkin:mainfrom
Conversation
…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>
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
selectNodefunction setsthis.currentNodebut never callsthis.map.focus(). The map'skeydownhandler 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 –
selectNodenow focuses the map (both extensions)Added
this.map.focus()right afterthis.currentNode = ein theselectNodefunction insideMindElixir.js:VS Code/MindElixir/MindElixir.jsVisual Studio/CodeMindMap/MindElixir/MindElixir.js2 – Dev webpack config now copies
MindElixir.jstoout/(VS Code extension)webpack.dev.config.jswas missingCopyWebpackPlugin, so runningbundle-dev/watchnever producedout/MindElixir/MindElixir.js. The webview couldn't load the library at all in development builds, causing a blank diagram. Added the sameCopyWebpackPluginpattern that already existed in the production config.