Skip to content

[WIKI-602] chore: disable image alignment tooltip for touch devices#7642

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
chore/disable-tooltip
Aug 25, 2025
Merged

[WIKI-602] chore: disable image alignment tooltip for touch devices#7642
sriramveeraghanta merged 2 commits intopreviewfrom
chore/disable-tooltip

Conversation

@1akhanBaheti
Copy link
Member

@1akhanBaheti 1akhanBaheti commented Aug 25, 2025

Description

This PR disables the tooltip for the image alignment action for touch devices.

Type of Change

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

Summary by CodeRabbit

  • New Features
    • Improved touch-device experience in the image alignment toolbar: tooltips are automatically disabled to prevent accidental overlays and enhance usability.
    • The toolbar now adapts its behavior based on device type, ensuring smoother interactions on touch screens.
    • Added a CSS utility to disable text selection on touch devices, reducing unintended selections during editing.
    • Overall, interactions within the image toolbar are more responsive and intuitive on mobile and tablet devices.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

Walkthrough

Adds an isTouchDevice boolean prop to image alignment toolbar components and wires it through the toolbar root. Tooltips in alignment UI are disabled on touch devices. Introduces a CSS utility class (.touch-select-none) to prevent text selection, without modifying existing selectors.

Changes

Cohort / File(s) Summary
Image toolbar alignment touch handling
packages/editor/src/core/extensions/custom-image/components/toolbar/alignment.tsx, packages/editor/src/core/extensions/custom-image/components/toolbar/root.tsx
Adds and forwards isTouchDevice prop; conditionally disables outer and option tooltips in alignment action based on touch capability; no other logic changes.
Editor CSS utilities
packages/editor/src/styles/editor.css
Adds .touch-select-none class with user-select: none and -webkit-user-select: none.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Root as ImageToolbarRoot
  participant Align as ImageAlignmentAction
  participant TT as Tooltip(s)

  User->>Root: Open image toolbar
  Root->>Align: Render with isTouchDevice
  alt isTouchDevice = true
    Align->>TT: Render tooltips (disabled)
    note right of TT: Tooltips disabled on touch
  else isTouchDevice = false
    Align->>TT: Render tooltips (enabled)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

🌐frontend

Suggested reviewers

  • VipinDevelops

Poem

A paw-tap, a hop, I test the screen—
Tooltips hush where touch has been.
CSS sprinkles “select-none” grace,
While icons align in tidy place.
Thump-thump! the toolbar’s feeling plush—
For paws and clicks alike—no fuss. 🐇✨

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 chore/disable-tooltip

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

makeplane bot commented Aug 25, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/editor/src/core/extensions/custom-image/components/toolbar/alignment.tsx (1)

35-43: Add accessible names to icon-only buttons (tooltip isn’t a label).

With tooltips disabled on touch, these icon-only buttons have no accessible name. Add aria-label to the trigger and each option for screen readers and general a11y. Also expose popup state on the trigger.

       <Tooltip disabled={isTouchDevice} tooltipContent="Align">
         <button
           type="button"
+          aria-label="Image alignment"
+          aria-haspopup="menu"
+          aria-expanded={isDropdownOpen}
           className="h-full flex items-center gap-1 text-white/60 hover:text-white transition-colors"
           onClick={() => setIsDropdownOpen((prev) => !prev)}
         >
-            <Tooltip disabled={isTouchDevice} key={option.value} tooltipContent={option.label}>
+            <Tooltip disabled={isTouchDevice} key={option.value} tooltipContent={option.label}>
               <button
                 type="button"
+                aria-label={option.label}
                 className="flex-shrink-0 h-full grid place-items-center text-white/60 hover:text-white transition-colors"
                 onClick={() => {
                   handleChange(option.value);
                   setIsDropdownOpen(false);
                 }}
               >
                 <option.icon className="size-3" />
               </button>
             </Tooltip>

Also applies to: 48-58

🧹 Nitpick comments (4)
packages/editor/src/styles/editor.css (1)

503-508: Consider suppressing iOS callout as well.

Nice utility. To further reduce long-press distractions on iOS Safari, also set -webkit-touch-callout: none;. Safe, small, and aligned with the intention here.

 /* touch device styles */
 .touch-select-none {
   user-select: none;
   -webkit-user-select: none;
+  -webkit-touch-callout: none;
 }
packages/editor/src/core/extensions/custom-image/components/toolbar/root.tsx (2)

11-21: Prop threading looks good; consider a backward-compatible optional prop + local default.

If any external caller renders ImageToolbarRoot without isTouchDevice, making it optional avoids breakage while keeping runtime behavior intact by defaulting to false.

 type Props = {
   alignment: TCustomImageAlignment;
   editor: Editor;
   aspectRatio: number;
   downloadSrc: string;
   handleAlignmentChange: (alignment: TCustomImageAlignment) => void;
   height: string;
-  isTouchDevice: boolean;
+  isTouchDevice?: boolean;
   src: string;
   width: string;
 };

Additionally (outside the changed range), default it locally:

// current line 24
const { alignment, editor, downloadSrc, handleAlignmentChange, isTouchDevice = false } = props;

Also applies to: 45-46


33-38: Apply the new no-select utility on touch to the toolbar wrapper.

Prevents accidental text selection when interacting with the toolbar on touch devices.

Example change outside the changed range:

<div
  className={cn(
    "absolute top-1 right-1 h-7 z-20 bg-black/80 rounded flex items-center gap-2 px-2 opacity-0 pointer-events-none group-hover/image-component:opacity-100 group-hover/image-component:pointer-events-auto transition-opacity",
    {
      "opacity-100 pointer-events-auto": shouldShowToolbar,
    },
    isTouchDevice && "touch-select-none"
  )}
>
packages/editor/src/core/extensions/custom-image/components/toolbar/alignment.tsx (1)

35-43: Optional: use pointer events for snappier touch response.

onPointerDown tends to feel more responsive on touch than onClick (which is delayed in some environments). If you switch, prevent default to avoid focus quirks.

-          onClick={() => setIsDropdownOpen((prev) => !prev)}
+          onPointerDown={(e) => {
+            e.preventDefault();
+            setIsDropdownOpen((prev) => !prev);
+          }}
📜 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 bbc465a and d48c863.

📒 Files selected for processing (3)
  • packages/editor/src/core/extensions/custom-image/components/toolbar/alignment.tsx (3 hunks)
  • packages/editor/src/core/extensions/custom-image/components/toolbar/root.tsx (1 hunks)
  • packages/editor/src/styles/editor.css (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). (3)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Build and lint web apps
🔇 Additional comments (4)
packages/editor/src/core/extensions/custom-image/components/toolbar/root.tsx (1)

11-21: ImageToolbarRoot isTouchDevice prop is correctly supplied at all call sites

All inspected instances of <ImageToolbarRoot … /> now explicitly pass isTouchDevice={isTouchDevice}, and the component itself defines isTouchDevice as a required prop (no default), so there are no omissions to address.

• In packages/editor/src/core/extensions/custom-image/components/block.tsx (around the showImageToolbar render), the toolbar is instantiated with
… isTouchDevice={isTouchDevice} ….
• The ImageToolbarRoot definition (packages/editor/src/core/extensions/custom-image/components/toolbar/root.tsx) declares isTouchDevice: boolean on its Props with no fallback, enforcing explicit provision.

No further changes are needed.

packages/editor/src/core/extensions/custom-image/components/toolbar/alignment.tsx (3)

34-44: LGTM: Tooltips are correctly gated off on touch devices.

Disabling both the trigger tooltip and per-option tooltips when isTouchDevice is true matches the PR objective and avoids hover-only affordances on touch.

Also applies to: 47-59


34-44: No changes needed for disabled prop on Tooltip

The Tooltip component in packages/ui/src/tooltip/tooltip.tsx explicitly defines and defaults a disabled?: boolean prop and forwards it to Blueprint’s Tooltip2 under the hood (see lines 28, 41, 78). Therefore, wrapping or conditional rendering around <Tooltip> solely to gate disabled isn’t necessary.

– packages/ui/src/tooltip/tooltip.tsx:
• ITooltipProps includes disabled?: boolean
• Default disabled = false in component signature
<Tooltip2 disabled={disabled} … /> in render

Likely an incorrect or invalid review comment.


13-15: No SSR hydration risk in isTouchDevice—it's entirely consumer-supplied
The editor library itself does not compute isTouchDevice from window or user-agent at render time—it’s declared as an optional prop (defaulting to false) and simply propagated through extensions and components. Any logic to detect touch capability must live in the embedding application, which should handle SSR vs. client-only detection. No changes are needed here.

@sriramveeraghanta sriramveeraghanta merged commit eb5ac2f into preview Aug 25, 2025
7 of 8 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore/disable-tooltip branch August 25, 2025 20:42
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.

3 participants