Skip to content

Create a child node when pressing Enter on the root node - #121

Merged
koppor merged 1 commit into
mainfrom
enter-on-root
Nov 15, 2026
Merged

koppor merged 1 commit into
mainfrom
enter-on-root

Conversation

@koppor

@koppor koppor commented Oct 26, 2026

Copy link
Copy Markdown
Member

Pressing Enter with the root node selected did nothing, because the root cannot have siblings. It now creates a child node, same as Insert; Enter on any other node still creates a sibling.

Test (no JabRef needed):

  • Select the root node, press Enter: a new child node opens for editing.
  • Select a non-root node, press Enter: a new sibling node is created.

🤖 Generated with Claude Code

The root has no siblings, so Enter did nothing there; it now behaves like Insert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@koppor
koppor marked this pull request as ready for review November 15, 2026 09:13
@koppor
koppor merged commit 384a8fe into main Nov 15, 2026
2 checks passed
@koppor
koppor deleted the enter-on-root branch November 15, 2026 09:13
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Make Enter create a child when the root node is selected

🐞 Bug fix 📝 Documentation 🕐 Less than 10 minutes

Grey Divider

AI Description

• Make Enter create a child when the root is selected, instead of doing nothing.
• Preserve sibling creation for other nodes and document the shortcut’s behavior.
Diagram

graph TD
  Enter["Enter key"] --> Mapping["Shortcut mapping"] --> Handler["Custom handler"] --> Root{"Root selected?"} -->|Yes| Child["Add child"]
  Root -->|No| Sibling["Add sibling"]
Loading
High-Level Assessment

Keep the small dispatch handler: it reuses jsMind’s existing creation paths, including selection and editing behavior. Duplicating node-creation logic or modifying the bundled shortcut provider would add maintenance cost for this focused fix.

Files changed (4) +11 / -2

Bug fix (2) +9 / -1
main.jsRoute Enter by selected-node type +8/-0

Route Enter by selected-node type

• Adds a shortcut handler that calls jsMind’s existing child-creation method for the root and sibling-creation method otherwise.

src/main.js

DefaultMindOptions.jsMap Enter to the context-aware handler +1/-1

Map Enter to the context-aware handler

• Replaces Enter’s direct sibling-creation mapping with the new named handler. The existing child shortcuts remain unchanged.

src/mindPresets/DefaultMindOptions.js

Documentation (2) +2 / -1
CHANGELOG.mdRecord the root-node Enter behavior +1/-0

Record the root-node Enter behavior

• Adds an unreleased changelog entry noting that Enter creates a child when the root is selected.

CHANGELOG.md

shortcuts.mdClarify Enter’s context-dependent shortcut +1/-1

Clarify Enter’s context-dependent shortcut

• Documents that Enter creates a sibling for ordinary nodes and a child for the root.

shortcuts.md

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1)

Grey Divider


View low (1)
Informational
1. Enter on root depends on key order to win 🐞 Bug
Description
The default jsMind option addbrother: 13 is still in the effective shortcut mapping because
merge_option deep-merges and never removes it, so keycode 13 is now bound by two names.
ShortcutProvider.init writes _mapping[13] once per name in insertion order, and the new
addBrotherOrChild entry is last, so it currently wins. A future change that reorders these keys or
re-adds addbrother to the app mapping would silently send Enter back to plain sibling creation,
which does nothing on the root.
Code

src/mindPresets/DefaultMindOptions.js[29]

+            addBrotherOrChild: 13,      // <Enter>
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The jsMind library default `shortcut.mapping` still binds Enter (13) to `addbrother`. The app now binds Enter to `addBrotherOrChild` in `src/mindPresets/DefaultMindOptions.js`. Both bindings are active, and the result depends on key insertion order in `ShortcutProvider.init`.

## Fix Focus Areas
- src/jsmind/src/jsmind.option.js[56-56]
- src/mindPresets/DefaultMindOptions.js[26-30]
- src/jsmind/src/jsmind.shortcut_provider.js[12-50]

## Recommended Fix
Either set `addbrother: false` in the app mapping in `DefaultMindOptions.js`. `init()` skips falsy mapping entries, so this disables the stale binding and makes the override explicit. Alternatively, remove `addbrother: 13` from the library default in `jsmind.option.js`, since the app is the only consumer. Add a short comment explaining why, so the override does not depend on key order.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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.

1 participant