Skip to content

feat(editor): add inspector hooks#3172

Open
joaopcm wants to merge 19 commits intocanaryfrom
feat/inspector-hooks
Open

feat(editor): add inspector hooks#3172
joaopcm wants to merge 19 commits intocanaryfrom
feat/inspector-hooks

Conversation

@joaopcm
Copy link
Copy Markdown
Member

@joaopcm joaopcm commented Apr 2, 2026

Summary

  • Ports 6 hooks from feat(editor): inspector #3107: use-collapsible-sections, use-document-colors, use-link-mark, use-drag-to-change, use-numeric-input
  • Adds tests for use-drag-to-change (7 tests) and use-numeric-input (13 tests)
  • Includes ported use-collapsible-sections.spec.ts (28 tests)
  • Total: 47 tests passing

Stacks on #3170


Summary by cubic

Adds four inspector hooks for colors, links, drag-to-change, and numeric inputs in the editor inspector. Includes tests, removes use-collapsible-sections, restores @react-email/* test stubs, and applies lint/review fixes.

  • New Features

    • use-document-colors: Finds unique hex colors from theme CSS and inline styles; normalizes to 6-digit; skips black/white.
    • use-link-mark: Reads link href/style/isActive; helpers getLinkColor and updateLinkColor.
    • use-drag-to-change: Horizontal drag to change numbers; step, Shift×10; min clamp; sets cursor and user-select.
    • use-numeric-input: Arrow inc/dec (Shift×10), min clamp, empty handling; Enter/blur commit; Escape restores; optional fallbackValue.
  • Refactors

    • Remove use-collapsible-sections.
    • Restore test stubs for @react-email/render, @react-email/markdown, and @react-email/components.
    • Minor biome lint and review feedback fixes.

Written for commit ff14097. Summary will update on new commits.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

⚠️ No Changeset found

Latest commit: ff14097

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

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

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

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Apr 2, 2026 8:20pm
react-email-demo Ready Ready Preview, Comment Apr 2, 2026 8:20pm
react-email-examples Ready Ready Preview, Comment Apr 2, 2026 8:20pm

Request Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

Open in StackBlitz

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

commit: ff14097

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

3 issues found across 8 files

Confidence score: 2/5

  • There are concrete user-facing regressions in packages/editor/src/ui/inspector/hooks/use-numeric-input.ts: pressing Escape can still persist edits on blur, which breaks expected cancel behavior.
  • packages/editor/src/ui/inspector/hooks/use-numeric-input.ts also mis-handles valid 0 during arrow key increment/decrement because || falls back incorrectly, so numeric edits can produce wrong values.
  • Given the high severity/confidence on both input-handling bugs, this carries high merge risk until those paths are corrected.
  • Pay close attention to packages/editor/src/ui/inspector/hooks/use-numeric-input.ts, packages/editor/src/ui/inspector/hooks/use-drag-to-change.ts - cancel/commit behavior, zero-value stepping logic, and drag cleanup on pointer cancellation need verification.
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/inspector/hooks/use-numeric-input.ts">

<violation number="1" location="packages/editor/src/ui/inspector/hooks/use-numeric-input.ts:80">
P1: Escape can still commit the edited value on blur, so canceling edits may incorrectly persist changes.</violation>

<violation number="2" location="packages/editor/src/ui/inspector/hooks/use-numeric-input.ts:105">
P1: Arrow key increments/decrements mis-handle valid `0` because `||` falls through to `fallbackValue`.</violation>
</file>

<file name="packages/editor/src/ui/inspector/hooks/use-drag-to-change.ts">

<violation number="1" location="packages/editor/src/ui/inspector/hooks/use-drag-to-change.ts:71">
P2: Handle pointer cancellation the same as pointer up so drag cleanup always runs.</violation>
</file>

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

joaopcm added 4 commits April 2, 2026 16:01
- Remove inspector.css (deferred to primitives PR)
- Remove unused @radix-ui/react-slot dependency
- Fix sidebar overflow in document-inspector example
@joaopcm joaopcm force-pushed the feat/inspector-utils-config branch from 3871bef to fd0246f Compare April 2, 2026 19:22
@joaopcm joaopcm force-pushed the feat/inspector-hooks branch from f3452c2 to 61aaa75 Compare April 2, 2026 19:23
@joaopcm
Copy link
Copy Markdown
Member Author

joaopcm commented Apr 2, 2026

Auto-merge enabled (squash) via PR Sentinel.

@joaopcm joaopcm requested a review from gabrielmfern April 2, 2026 20:09
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.

1 participant