Skip to content

[ENG-1582] Node menu hotkey on text selection#917

Open
trangdoan982 wants to merge 1 commit intomainfrom
eng-1582-modify-the-node-menu-key-so-that-if-theres-no-text-selection
Open

[ENG-1582] Node menu hotkey on text selection#917
trangdoan982 wants to merge 1 commit intomainfrom
eng-1582-modify-the-node-menu-key-so-that-if-theres-no-text-selection

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Mar 26, 2026

Summary

  • When the node tag hotkey is pressed without text selected, the existing candidate node tag popover opens as before
  • When pressed with text selected, a new inline node type picker appears showing all node types
  • Selecting a node type creates a discourse node from the selected text and replaces it with a [[wiki-link]]

Closes ENG-1582

Test plan

https://www.loom.com/share/3df52ae11a884fa5adc749487066e501

  • Press node tag hotkey with no selection → tag popover opens (regression)
  • Select text, press hotkey → node type picker appears near cursor
  • Pick a node type → new file created, selection replaced with [[formatted-name]]
  • Press Escape → picker closes without changes
  • Arrow keys + Enter navigate and select in the picker
  • Selected text with invalid filename chars → Notice shown
image

🤖 Generated with Claude Code


Open with Devin

When the node tag hotkey is pressed with text selected, open an inline
node type picker instead of the tag popover. Selecting a node type
creates a discourse node from the selected text and replaces it with
a wiki-link.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@supabase
Copy link

supabase bot commented Mar 26, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Comment on lines +158 to +161
const newIndex = Math.min(
this.selectedIndex + 1,
this.items.length - 1,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

When items.length is 0, this calculation produces -1 as the new index:

Math.min(this.selectedIndex + 1, this.items.length - 1)
// When items.length = 0: Math.min(1, -1) = -1

This sets selectedIndex to -1, which is invalid. Add a guard check:

if (e.key === "ArrowDown") {
  e.preventDefault();
  e.stopPropagation();
  if (this.items.length === 0) return;
  const newIndex = Math.min(
    this.selectedIndex + 1,
    this.items.length - 1,
  );
  this.updateSelectedIndex(newIndex);
  this.scrollToSelected();
}

The same guard should be added to the ArrowUp handler.

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@trangdoan982 trangdoan982 requested a review from mdroidian March 26, 2026 20:30
@trangdoan982 trangdoan982 changed the title [ENG-1582] Branch node menu hotkey on text selection [ENG-1582] Node menu hotkey on text selection Mar 27, 2026
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