Refactor: Extract toolbar drag logic into createToolbarDrag primitive#248
Merged
Refactor: Extract toolbar drag logic into createToolbarDrag primitive#248
Conversation
…s the application. Replace PANEL_STYLES with "bg-white" in multiple components to standardize appearance.
…ents for enhanced clarity and maintainability. Adjust event handling in context menus and toolbars to streamline user interactions.
Move drag interaction (pointer tracking, velocity, snap calculation, drag-aware click handling) out of the 1608-line toolbar component into a focused SolidJS primitive. Extract pure position functions (calculateExpandedPositionFromCollapsed, getCollapsedPosition) into toolbar-position.ts. Toolbar reduced from 1608 to ~1390 lines. All 584 e2e tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Error agent completed without reporting progress |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Resolve conflicts by keeping our extracted createToolbarDrag primitive and position utility functions that main had removed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@react-grab/cli
grab
@react-grab/amp
@react-grab/claude-code
@react-grab/codex
@react-grab/copilot
@react-grab/cursor
@react-grab/droid
@react-grab/gemini
@react-grab/opencode
react-grab
@react-grab/relay
@react-grab/utils
commit: |
The shared registerOverlayDismiss utility unconditionally filtered right-clicks (event.button === 2), but this check only existed in the original ContextMenu code. ClearHistoryPrompt and ToolbarMenu dismissed on any mousedown including right-clicks. Add shouldIgnoreRightClick option (default false) and only enable it for ContextMenu to restore original per-component behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
toolbar/index.tsxinto a newcreateToolbarDragSolidJS primitive (utils/create-toolbar-drag.ts)calculateExpandedPositionFromCollapsed,getCollapsedPosition) intoutils/toolbar-position.tsonDragStartcallback fired on every pointermove after threshold instead of onceonDragEndcallback, unused exports (velocity,hasDragMoved), and convertdragOffsetfrom signal to plain variableToolbar reduced from 1608 to ~1390 lines (-13%). No behavioral changes — regression-reviewed against original code.
Test plan
pnpm typecheckpassespnpm lintpasses (0 warnings, 0 errors)🤖 Generated with Claude Code
Note
Medium Risk
Moderate risk because it refactors pointer/drag/snapping behavior and related event listeners/timeouts; small logic mistakes could break toolbar movement or click handling. Overlay dismiss right-click behavior is now configurable and could affect dismissal in other overlays if misused.
Overview
Refactors toolbar drag/snapping logic by extracting pointer tracking, velocity-based snapping, snap animation timing, and drag-aware click suppression into a new
createToolbarDragprimitive, and wiringToolbarto usedrag.handlePointerDown,drag.isDragging, anddrag.isSnapping.Moves position math into shared utilities by adding
calculateExpandedPositionFromCollapsedandgetCollapsedPositiontotoolbar-position.ts, removing duplicated inline calculations and simplifying collapse/expand positioning.Behavioral tweak:
registerOverlayDismissnow supports an optionalshouldIgnoreRightClickflag;ContextMenuopts in so right-clicks outside don’t dismiss it.Written by Cursor Bugbot for commit 31dac51. This will update automatically on new commits. Configure here.
Summary by cubic
Extracted toolbar drag/snapping into a reusable
createToolbarDragprimitive and moved position math totoolbar-position, cutting toolbar size by ~13% with no behavior changes. Also made right-click filtering opt-in inregisterOverlayDismissto restore per-component behavior.Refactors
utils/create-toolbar-dragfor pointer tracking, velocity, snapping, and drag-aware click; toolbar now usesdrag.handlePointerDown,drag.isDragging, anddrag.isSnapping.utils/toolbar-position(calculateExpandedPositionFromCollapsed,getCollapsedPosition); toolbar calls a small wrapper for clarity.mainand resolved conflicts in favor of the new primitive and position utilities.Bug Fixes
onDragStartfires once after the threshold instead of on every pointermove.registerOverlayDismiss; enabled only forContextMenuto match original behavior.Written for commit 31dac51. Summary will update on new commits.