Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apps/client/src/widgets/note_map/NoteMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {

// Interaction
graph
.onNodeClick((node) => {
.onNodeClick((node, event) => {
if (!node.id) return;

// Cmd (macOS) / Ctrl (Windows/Linux) + click opens the target note in a split.
if (isSplitModifierClick(event as MouseEvent | undefined)) {
const ntxId = appContext.tabManager.getActiveContext()?.ntxId;
appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath: node.id });
Comment on lines +82 to +83
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's possible for appContext.tabManager.getActiveContext() to return null, which would result in ntxId being undefined. The openNewNoteSplit command might require a valid ntxId to function correctly. Other parts of the codebase, such as link_context_menu.ts, include a guard to ensure ntxId is present before triggering a similar command.

To improve robustness and prevent potential silent failures, it would be best to add a check for ntxId before triggering the command. While TASKS_PLAN.md indicates that a fallback behavior is planned for a future task (T1.2), an explicit guard is a good practice for now.

                        const ntxId = appContext.tabManager.getActiveContext()?.ntxId;
                        if (ntxId) {
                            appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath: node.id });
                        }

return;
}

appContext.tabManager.getActiveContext()?.setNote(node.id);
})
.onNodeRightClick((node, e) => {
Expand Down Expand Up @@ -172,3 +180,7 @@ function getCssData(container: HTMLElement, styleResolver: HTMLElement): CssData
mutedTextColor: rgb2hex(styleResolverStyle.color)
}
}

function isSplitModifierClick(event: MouseEvent | undefined) {
return !!(event?.metaKey || event?.ctrlKey);
}