-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[WEB-5415] fix: enter handler for emoji #8108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: preview
Are you sure you want to change the base?
Conversation
WalkthroughChanges introduce emoji picker integration into the editor's keyboard handling system. A DOM identifier is added to the emoji picker container, node priority is configured for the emoji extension, and the editor's Enter key handler defers to the emoji picker when active. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Editor as Editor (keydown handler)
participant Emoji as Emoji Picker
User->>Editor: Presses Enter
alt Emoji Picker (`#emojis-picker`) is visible
Editor->>Editor: Check for emoji picker element
Editor->>Emoji: Defer handling to emoji picker
Emoji->>User: Handle emoji selection
else Emoji Picker not visible
Editor->>Editor: Continue with slash-command handling
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/editor/src/core/extensions/emoji/components/emojis-list.tsx (1)
124-124: LGTM! Consider extracting the ID as a constant.The
id="emojis-picker"addition enables the Enter key handling fix inprops.ts. The approach is simple and effective.For better maintainability, consider extracting this ID as a shared constant to avoid string duplication between this file and
props.ts:// In a shared constants file: export const EMOJIS_PICKER_ID = "emojis-picker";Then use it in both locations:
- id="emojis-picker" + id={EMOJIS_PICKER_ID}packages/editor/src/core/props.ts (1)
22-27: LGTM! Consider refactoring to reduce duplication.The Enter key handling for the emoji picker correctly prevents default behavior when the picker is active, fixing the reported issue.
The logic duplicates the pattern used for slash commands (lines 29-34). Consider refactoring to reduce code duplication:
keydown: (_view, event) => { - // prevent default event listeners from firing when slash command is active - if (["Enter"].includes(event.key)) { - const emojisPicker = document.querySelector("#emojis-picker"); - if (emojisPicker) { - return true; - } - } - - if (["ArrowUp", "ArrowDown", "Enter"].includes(event.key)) { - const slashCommand = document.querySelector("#slash-command"); - if (slashCommand) { - return true; - } - } + // prevent default event listeners when suggestion dropdowns are active + const activeDropdowns = [ + { keys: ["Enter"], selector: "#emojis-picker" }, + { keys: ["ArrowUp", "ArrowDown", "Enter"], selector: "#slash-command" }, + ]; + + for (const { keys, selector } of activeDropdowns) { + if (keys.includes(event.key) && document.querySelector(selector)) { + return true; + } + } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/editor/src/core/extensions/emoji/components/emojis-list.tsx(1 hunks)packages/editor/src/core/extensions/emoji/emoji.ts(1 hunks)packages/editor/src/core/props.ts(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). (4)
- GitHub Check: Agent
- GitHub Check: CodeQL analysis (javascript-typescript)
- GitHub Check: Build and lint web apps
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/editor/src/core/extensions/emoji/emoji.ts (1)
82-82: Emoji extension priority verified—no conflicts found.The
priority: 1001is intentionally set higher than other extensions (utility and custom-link at 1000), ensuring emoji processes first in the event chain. All remaining extensions use the default priority, so there are no conflicts or inadvertent overrides.
Description
fix enter handler for emoji
Type of Change
Screenshots and Media (if applicable)
Screen.Recording.2025-11-13.at.1.35.10.PM.mov
Test Scenarios
References
Summary by CodeRabbit