Skip to content

feat: add ButtonBubbleMenu compound component primitives#3016

Open
joaopcm wants to merge 8 commits intofeat/ai-oss-editorfrom
feat/editor-button-bubble-menu-primitives
Open

feat: add ButtonBubbleMenu compound component primitives#3016
joaopcm wants to merge 8 commits intofeat/ai-oss-editorfrom
feat/editor-button-bubble-menu-primitives

Conversation

@joaopcm
Copy link
Member

@joaopcm joaopcm commented Mar 5, 2026

Summary

  • New ButtonBubbleMenu compound primitives: Root, Toolbar, EditLink
  • Context: useButtonBubbleMenuContext hook for consumer state sync
  • Minimal layout CSS with data-re-btn-bm-* attribute selectors
  • Fix LinkBubbleMenu.Root default placement from bottom to top
  • Bump to 0.0.0-experimental.11

Components

Component Purpose
Root Wraps tiptap BubbleMenu, shouldShow on button node, manages isEditing state
Toolbar Conditional wrapper, hides when isEditing
EditLink Button to enter edit mode, default LinkIcon, composed onClick

Linear

PRODUCT-1508


Summary by cubic

Adds ButtonBubbleMenu primitives (Root, Toolbar, EditLink) with shared context and minimal CSS to support a simple, composable button editing menu with link edit mode (PRODUCT-1508). Also updates LinkBubbleMenu defaults and event handling for consistency.

  • New Features

    • ButtonBubbleMenu: Root shows when a button node is active and manages isEditing; Toolbar hides while editing; EditLink enters edit mode and composes onClick.
    • Shared hook (useButtonBubbleMenuContext) for editor and isEditing state.
    • Minimal layout CSS via data-re-btn-bm* attributes; exports added to UI index.
  • Bug Fixes

    • LinkBubbleMenu.Root default placement changed to top.
    • LinkBubbleMenu EditLink and Unlink now compose onMouseDown, preventing blur while preserving consumer handlers.

Written for commit 3e6baa9. Summary will update on new commits.

@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Mar 5, 2026 8:14pm
react-email-demo Ready Ready Preview, Comment Mar 5, 2026 8:14pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

⚠️ No Changeset found

Latest commit: 3e6baa9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/editor@3016

commit: 3e6baa9

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 14 files

Confidence score: 4/5

  • This PR is likely safe to merge with minimal risk; the reported issue is moderate (5/10) and focused on event-handler composition rather than core functionality.
  • In packages/editor/src/ui/button-bubble-menu/edit-link.tsx, consumer-provided onMouseDown is currently overridden, which can break custom integrations that rely on that handler.
  • Composing onMouseDown the same way onClick is composed should preserve existing custom behavior and reduce regression risk for downstream consumers.
  • Pay close attention to packages/editor/src/ui/button-bubble-menu/edit-link.tsx - ensure onMouseDown is composed instead of replaced so consumer behavior is retained.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/editor/src/ui/button-bubble-menu/edit-link.tsx">

<violation number="1" location="packages/editor/src/ui/button-bubble-menu/edit-link.tsx:24">
P2: This overrides and drops any consumer-provided `onMouseDown` handler. Compose the handler (as done for `onClick`) so custom behavior is preserved.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@joaopcm joaopcm changed the title feat: ButtonBubbleMenu compound component primitives feat: add ButtonBubbleMenu compound component primitives Mar 5, 2026
@joaopcm joaopcm self-assigned this Mar 5, 2026
setIsEditing(true);
}}
>
{children ?? <LinkIcon />}
Copy link
Member

Choose a reason for hiding this comment

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

should we provide lucide as a default like this? I think we should assume no icon, and let the user pass in children and style to make the icon they want to use work

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the default we've been doing for the other bubble menus, but we can totally change it. I'd do it in a follow-up PR and cover all of the existing components in a single PR

data-item="unlink"
className={className}
onMouseDown={(e) => e.preventDefault()}
onMouseDown={(e) => {
Copy link
Member

Choose a reason for hiding this comment

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

should we maybe inlcude these in a separate pr? not trying to be nitpicky here tho

Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally, yes, but since this is an experimental version, I don't think it's a big deal. I'll make sure to isolate unrelated changes better next time. Just wanted to move fast while we can :)

import * as React from 'react';
import { ButtonBubbleMenuContext } from './context';

export interface ButtonBubbleMenuRootProps {
Copy link
Member

Choose a reason for hiding this comment

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

should this also extend React.ComponentProps of something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! Good call

expect(container.querySelector('[data-re-btn-bm-toolbar]')).toBeNull();
});

it('applies className', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how useful this test is, and if it might be increasing the test count and giving us a kind of fake confidence that things are stable without much meaning since it asserts behavior that's not really very fragile

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, this component stopping applying className would indeed be a problem. I think it's fair to keep this test and make sure built-in components are customizable via the standard className prop

),
}));

describe('ButtonBubbleMenuRoot', () => {
Copy link
Member

Choose a reason for hiding this comment

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

is this maybe already ensured for us by typescript?

* Import optionally: import '@react-email/editor/styles/button-bubble-menu.css';
*/

[data-re-btn-bm] {
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering how necessary this css is. Is this kind of thing a common pattern for other composable/unstyled popular libraries out there?

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.

2 participants