Skip to content

[WIKI-713] fix: extra line created on enter key#7913

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
fix/editor-mention-enter-key
Oct 7, 2025
Merged

[WIKI-713] fix: extra line created on enter key#7913
sriramveeraghanta merged 1 commit intopreviewfrom
fix/editor-mention-enter-key

Conversation

@Palanikannan1437
Copy link
Member

@Palanikannan1437 Palanikannan1437 commented Oct 7, 2025

Description

An extra line was created on pressing the enter key every time while mentioning users

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of keyboard navigation in mentions and slash command menus.
    • Enter key consistently selects the highlighted item.
    • Non-navigation keys no longer trigger unintended menu behavior.
  • Accessibility

    • Enhanced keyboard-only interaction for mentions and slash command dropdowns, ensuring predictable focus and selection behavior.

@makeplane
Copy link

makeplane bot commented Oct 7, 2025

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 7, 2025

Walkthrough

Keyboard event handlers in MentionsListDropdown and CommandMenu were updated to consistently return explicit boolean values (true/false) for non-navigation, navigation, and Enter key paths, adjusting control flow without changing public APIs or component structures.

Changes

Cohort / File(s) Summary of changes
Keyboard event return normalization — Mentions
packages/editor/src/core/extensions/mentions/mentions-list-dropdown.tsx
onKeyDown now returns false for non-navigation keys, returns true after Enter selection, and explicitly returns true after handling navigation.
Keyboard event return normalization — Slash commands
packages/editor/src/core/extensions/slash-commands/command-menu.tsx
Imperative onKeyDown now returns false for non-navigation keys, returns true after Enter selection, and returns true after processing a computed next index.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant C as Component (Mentions/CommandMenu)
  participant K as onKeyDown Handler
  participant S as Selector/State

  U->>C: Key press
  C->>K: onKeyDown(event)
  alt Non-navigation key
    K-->>C: return false
  else Navigation key (ArrowUp/Down, etc.)
    K->>S: compute next index
    S-->>K: updated index
    K-->>C: return true
  else Enter
    K->>S: selectItem()
    K-->>C: return true
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend, ✍️editor

Suggested reviewers

  • pushya22

Poem

I tap-tap keys with whiskered grace,
Arrows dance, selections trace—
Enter hops and choices bloom,
False or true decides the room.
In dropdown fields I swiftly tread,
A savvy bun with keybound tread. 🐇⌨️

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description correctly outlines the bug and marks it as a non-breaking fix but omits required sections for test scenarios and references and does not include the optional screenshots and media section from the repository template. Please expand the PR description to include a “Test Scenarios” section detailing how the change was verified and a “References” section linking related issues, and add “Screenshots and Media” if applicable per the template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the key change by indicating it fixes the extra line creation on Enter key and directly relates to the main bug being addressed without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/editor-mention-enter-key

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 298acb1 and 7a57f90.

📒 Files selected for processing (2)
  • packages/editor/src/core/extensions/mentions/mentions-list-dropdown.tsx (2 hunks)
  • packages/editor/src/core/extensions/slash-commands/command-menu.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/editor/src/core/extensions/mentions/mentions-list-dropdown.tsx (1)

50-69: LGTM! Keyboard event handling correctly prevents extra line insertion.

The explicit boolean returns fix the reported bug:

  • Line 51: Returning false for non-navigation keys allows default behavior
  • Line 56: Returning true after selectItem prevents the default Enter behavior (which was causing the extra line)
  • Line 68: Returning true after navigation logic prevents default arrow key behavior

These changes ensure proper event handling and fix the extra line issue when mentioning users.

packages/editor/src/core/extensions/slash-commands/command-menu.tsx (1)

92-113: LGTM! Consistent keyboard event handling fixes the extra line bug.

The changes align with the mentions dropdown fix:

  • Line 93: Returning false for non-navigation keys allows default behavior
  • Line 98: Returning true after selectItem prevents the default Enter behavior
  • Line 111: Returning true after navigation logic prevents default behavior

The explicit boolean returns make event handling predictable and fix the reported issue.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sriramveeraghanta sriramveeraghanta merged commit a740a9f into preview Oct 7, 2025
6 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix/editor-mention-enter-key branch October 7, 2025 08:52
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.

3 participants