Skip to content

[WIKI-550] fix: emoji modal for touch device#7651

Merged
sriramveeraghanta merged 4 commits intopreviewfrom
fix-emoji_suggestion_mobile
Aug 26, 2025
Merged

[WIKI-550] fix: emoji modal for touch device#7651
sriramveeraghanta merged 4 commits intopreviewfrom
fix-emoji_suggestion_mobile

Conversation

@iam-vipin
Copy link
Copy Markdown
Member

@iam-vipin iam-vipin commented Aug 26, 2025

Description

This PR check for isTouch device and disable emoji suggestion it.

  • Improvement (change that would cause existing functionality to not work as expected)

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • Bug Fixes
    • Emoji suggestion dropdown no longer opens on touch-enabled devices, avoiding obstructive overlays and accidental emoji insertions while typing.
    • Improves usability and stability on mobile phones and tablets.
    • Desktop and non-touch behavior remains unchanged; suggestions still appear as before.
    • No user action or settings changes required.
    • Ensures a smoother typing experience on touch devices.

Copilot AI review requested due to automatic review settings August 26, 2025 10:02
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Expose emojiSuggestion as a named export (removed default export), add a runtime touch-device guard that disables emoji ProseMirror plugins, and update the Emoji extension to import the named emojiSuggestion. No other logic changes.

Changes

Cohort / File(s) Summary
Emoji suggestion export change
packages/editor/src/core/extensions/emoji/suggestion.ts
Converted emojiSuggestion from a private constant to a named export (export const emojiSuggestion...) and removed export default emojiSuggestion;. Internal suggestion object unchanged.
Touch-device guard for emoji plugins
packages/editor/src/core/extensions/emoji/emoji.ts
Added runtime guard in addProseMirrorPlugins to read isTouchDevice from extension utility storage (getExtensionStorage(...).isTouchDevice) and return an empty plugin list on touch devices; existing plugin behavior preserved for non-touch devices.
Extension import update
packages/editor/src/core/extensions/emoji/extension.ts
Replaced default import with a named import emojiSuggestion and updated the Emoji extension to use that named emojiSuggestion for its suggestion option.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Editor
    participant EmojiExt as Emoji Extension
    participant EmojiCore as Emoji Core (emoji.ts)
    participant Utility as Utility Storage

    User->>Editor: Trigger emoji flow (e.g., type ":")
    Editor->>EmojiExt: use suggestion / init
    EmojiExt->>EmojiCore: addProseMirrorPlugins()
    EmojiCore->>Utility: getExtensionStorage(...).isTouchDevice
    Utility-->>EmojiCore: isTouchDevice (true/false)

    alt isTouchDevice == true
        Note over EmojiCore: Return empty plugin list (plugins disabled)
        EmojiCore-->>EmojiExt: []
    else isTouchDevice == false
        Note over EmojiCore: Return emoji plugins (suggestion enabled)
        EmojiCore-->>EmojiExt: [emoji plugins...]
        EmojiExt->>EmojiCore: uses `emojiSuggestion` (named import)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

🐛bug

Suggested reviewers

  • Palanikannan1437
  • aaryan610

Poem

I nibble on code beneath the moon,
On touchy panes I skip the tune.
When keys click loud, my burrow wakes —
I sprinkle emojis in tiny flakes. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-emoji_suggestion_mobile

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@makeplane
Copy link
Copy Markdown

makeplane bot commented Aug 26, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR disables emoji suggestions on touch devices by checking for touch device status and preventing the emoji modal from appearing. The change improves the user experience on mobile and tablet devices where emoji suggestions may interfere with touch interactions.

  • Adds touch device detection to disable emoji suggestions on touch-enabled devices
  • Modifies the emoji suggestion onStart handler to exit early for touch devices

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/editor/src/core/extensions/emoji/suggestion.ts (2)

53-63: Optional: reuse utility storage and reduce duplicate lookups

Minor cleanup that also centralizes the storage reference:

       return {
         onStart: (props: SuggestionProps): void => {
-        const isTouchDevice = !!getExtensionStorage(props.editor, CORE_EXTENSIONS.UTILITY).isTouchDevice;
-        if (!props.clientRect || isTouchDevice) return;
-
-        editor = props.editor;
-
-        // Track active dropdown
-        getExtensionStorage(editor, CORE_EXTENSIONS.UTILITY).activeDropbarExtensions.push(CORE_EXTENSIONS.EMOJI);
+        const utilityStorage = getExtensionStorage(props.editor, CORE_EXTENSIONS.UTILITY);
+        const isTouchDevice = !!utilityStorage.isTouchDevice;
+        if (!props.clientRect || isTouchDevice) return;
+
+        editor = props.editor;
+
+        // Track active dropdown
+        utilityStorage.activeDropbarExtensions.push(CORE_EXTENSIONS.EMOJI);

2-2: Nit: make Editor a type-only import to avoid bundling runtime symbol

Editor is only used as a type. Use a type-only import to keep it out of the runtime bundle.

-import { ReactRenderer, Editor } from "@tiptap/react";
+import { ReactRenderer } from "@tiptap/react";
+import type { Editor } from "@tiptap/react";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cf7b288 and 3d6cd4f.

📒 Files selected for processing (1)
  • packages/editor/src/core/extensions/emoji/suggestion.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/editor/src/core/extensions/emoji/suggestion.ts (2)
packages/editor/src/core/helpers/get-extension-storage.ts (1)
  • getExtensionStorage (5-8)
packages/editor/src/index.ts (1)
  • CORE_EXTENSIONS (24-24)
⏰ 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: Build and lint web apps
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Build and lint web apps
🔇 Additional comments (1)
packages/editor/src/core/extensions/emoji/suggestion.ts (1)

55-56: Utility storage includes and initializes isTouchDevice

Verified in packages/editor/src/core/extensions/utility.ts that the UtilityExtensionStorage interface declares an isTouchDevice: boolean field, and the extension’s initializer (line 81) sets it from the incoming isTouchDevice prop. No further changes needed.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (1)
packages/editor/src/core/extensions/emoji/suggestion.ts (1)

57-61: Resolved: editor is now assigned before storage access

editor = props.editor precedes the storage push, fixing the earlier “editor is undefined” bug. Looks good.

🧹 Nitpick comments (3)
packages/editor/src/core/extensions/emoji/suggestion.ts (1)

13-13: Type source consistency (optional): import EmojiOptions from local extension to avoid drift

You’re importing EmojiOptions from @tiptap/extension-emoji while also defining a local EmojiOptions in emoji.ts. To avoid type drift, consider a type-only import from the local file.

-import type { EmojiOptions } from "@tiptap/extension-emoji";
+import type { EmojiOptions } from "./emoji";
packages/editor/src/core/extensions/emoji/emoji.ts (2)

19-22: New imports are fine; add a defensive optional chain to avoid hard crash if UTILITY storage is absent

If the UTILITY extension isn’t registered (or storage not initialized yet), direct property access can throw. Defensive ?. costs nothing and avoids editor init crashes.

-    const isTouchDevice = !!getExtensionStorage(this.editor, CORE_EXTENSIONS.UTILITY).isTouchDevice;
+    const isTouchDevice = !!getExtensionStorage(this.editor, CORE_EXTENSIONS.UTILITY)?.isTouchDevice;

346-350: Clarify emoji plugin disablement scope on touch devices

I’ve confirmed that isTouchDevice is defined in the Utility extension storage (e.g. packages/editor/src/core/extensions/utility.ts) and used throughout the editor codebase. As it stands, the early return [] in emoji.ts on touch devices disables both:

  • the Suggestion (typeahead) plugin, and
  • the standalone “emoji” plugin (double-click handling + unicode-to-node conversion)

If the intention is only to suppress the emoji suggestion modal on touch while retaining the conversion/UX plugin, I recommend refactoring to conditionally include only the Suggestion plugin. For example:

--- a/packages/editor/src/core/extensions/emoji/emoji.ts
+++ b/packages/editor/src/core/extensions/emoji/emoji.ts
@@ -344,11 +344,23 @@ export default class Emoji extends Extension {
   addProseMirrorPlugins() {
-    const isTouchDevice = !!getExtensionStorage(this.editor, CORE_EXTENSIONS.UTILITY).isTouchDevice;
-    if (isTouchDevice) {
-      return [];
-    }
-    return [
-      Suggestion({ /* … */ }),
-      new Plugin({ key: new PluginKey("emoji"), /* double-click & appendTransaction */ }),
-    ];
+    const isTouchDevice = !!getExtensionStorage(this.editor, CORE_EXTENSIONS.UTILITY)?.isTouchDevice;
+    const plugins: Plugin[] = [];
+
+    // Only disable the typeahead on touch; always include the core emoji plugin
+    if (!isTouchDevice) {
+      plugins.push(
+        Suggestion({
+          editor: this.editor,
+          findSuggestionMatch: customFindSuggestionMatch,
+          ...this.options.suggestion,
+        })
+      );
+    }
+
+    plugins.push(
+      new Plugin({
+        key: new PluginKey("emoji"),
+        props: {
+          handleDoubleClickOn: (view, pos, node) => { /* … */ },
+        },
+        appendTransaction: (transactions, oldState, newState) => { /* … */ },
+      })
+    );
+
+    return plugins;

— After this change:

  • Touch devices: colon (:) no longer opens the suggestion modal, but pasted/typed Unicode emojis still convert.
  • Desktop: both suggestion and conversion plugins remain active.

Let me know if this aligns with the product goal for touch–device behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 75782c1 and 45f4135.

📒 Files selected for processing (3)
  • packages/editor/src/core/extensions/emoji/emoji.ts (2 hunks)
  • packages/editor/src/core/extensions/emoji/extension.ts (2 hunks)
  • packages/editor/src/core/extensions/emoji/suggestion.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/editor/src/core/extensions/emoji/emoji.ts (1)
packages/editor/src/core/helpers/get-extension-storage.ts (1)
  • getExtensionStorage (5-8)
packages/editor/src/core/extensions/emoji/extension.ts (1)
packages/editor/src/core/extensions/emoji/suggestion.ts (1)
  • emojiSuggestion (13-118)
packages/editor/src/core/extensions/emoji/suggestion.ts (1)
packages/editor/src/core/extensions/emoji/emoji.ts (1)
  • EmojiOptions (73-79)
⏰ 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: Analyze (javascript)
  • GitHub Check: Build and lint web apps
🔇 Additional comments (2)
packages/editor/src/core/extensions/emoji/suggestion.ts (1)

13-13: emojiSuggestion named export migration is safe

No default imports of ./suggestion remain in the repo—only a single named import is used—so switching to a named export will not break any internal consumers. You can safely omit the temporary export default emojiSuggestion compatibility layer.

• Verified named import at
• packages/editor/src/core/extensions/emoji/extension.ts:6 — import { emojiSuggestion } from "./suggestion";

packages/editor/src/core/extensions/emoji/extension.ts (1)

6-6: Import and wire-up to named export confirmed

I’ve verified that there are no remaining default imports of ./suggestion in the packages/editor directory and that both occurrences (lines 6 and 28 of extension.ts) now correctly use the named import:

import { emojiSuggestion } from "./suggestion";

No further changes are needed here—everything is wired up as intended.

@sriramveeraghanta sriramveeraghanta merged commit 5d1ad8a into preview Aug 26, 2025
6 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-emoji_suggestion_mobile branch August 26, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants