-
Notifications
You must be signed in to change notification settings - Fork 191
refactor: to new canvas impl instead of DOM #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 6 files
- Enhanced the `getGrabbedBoxInfo` and `isGrabbedBoxVisible` functions to retrieve grabbed box information from the API state, improving accuracy in box visibility checks. - Updated type definitions in `types.ts` to ensure proper structure for `grabbedBoxes`, including `id`, `bounds`, and `createdAt` properties. - Refactored core component logic to utilize the updated grabbed boxes structure, ensuring consistent handling across the application.
- Changed the global name for the ReactGrab module to enhance compatibility with different environments. - Refactored various functions in the API to ensure they correctly access and utilize the updated global state, improving overall functionality and reliability. - Enhanced type definitions to better reflect the structure of the API state, ensuring consistency across the application.
- Updated the target element check in the API to use a more concise null check, enhancing code readability. - Ensured consistent handling of the canvas element retrieval, maintaining functionality across different environments.
- Enhanced the handling of device pixel ratio changes by adding event listeners for better responsiveness to window resizing and pixel ratio adjustments. - Refactored the setup and cleanup logic for media queries to ensure proper resource management and prevent memory leaks.
- Updated overlay canvas component to utilize constants for color and style definitions, improving maintainability and consistency. - Refactored the handling of crosshair and overlay styles to enhance visual clarity and responsiveness. - Adjusted type definitions in fixtures to ensure alignment with updated component logic.
- Updated the `waitForSelectionLabel` and `isSelectionBoxVisible` functions to improve their responsiveness and accuracy in detecting visibility states. - Refactored the handling of selection label information retrieval to ensure consistent behavior across different components. - Adjusted type definitions in `types.ts` to align with the updated logic for selection visibility, enhancing overall code clarity and maintainability.
- Updated the logic for determining the visibility of selection and drag boxes to improve accuracy and responsiveness. - Refactored the handling of visibility conditions to incorporate additional state checks, ensuring consistent behavior across components.
- Updated the input mode tests to improve the accuracy of clipboard content checks and input focus behavior. - Refactored selection visibility checks to ensure consistent behavior when interacting with elements. - Enhanced toolbar visibility tests to better handle viewport changes and rapid resizing scenarios.
- Updated the overlay canvas component to improve the handling of animated bounds, including target opacity and border radius. - Refactored the interpolation logic to ensure smoother transitions and better responsiveness to animation state changes. - Adjusted type definitions for animation properties to enhance clarity and maintainability.
There was a problem hiding this 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 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/react-grab/src/components/overlay-canvas.tsx">
<violation number="1" location="packages/react-grab/src/components/overlay-canvas.tsx:537">
P2: Magic number `0.01` used for opacity convergence threshold in two places. Consider extracting to a constant (e.g., `OPACITY_CONVERGENCE_THRESHOLD`) to keep both usages in sync.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this 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 7 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/react-grab/e2e/open-file.spec.ts">
<violation number="1" location="packages/react-grab/e2e/open-file.spec.ts:38">
P2: The `pressKeyCombo` action is being called inside the `expect.poll()` callback, which means it will be pressed repeatedly every 500ms until the condition passes. This masks timing issues and can cause flaky tests. The action should be performed once before the poll, then poll only the result. This pattern is repeated multiple times in this file.</violation>
<violation number="2" location="packages/react-grab/e2e/open-file.spec.ts:396">
P2: Loosening the assertion from `.toBe(1)` to `.toBeGreaterThanOrEqual(1)` (and `.toBe(2)` to `.toBeGreaterThanOrEqual(2)`) works around the repeated key press issue but makes the test less precise. Once the key press is moved outside the poll, the exact count assertions should be restored.</violation>
</file>
<file name="packages/react-grab/e2e/fixtures.ts">
<violation number="1" location="packages/react-grab/e2e/fixtures.ts:297">
P2: The strict inequality check `!== null` will incorrectly pass when `selectionFilePath` is `undefined` (since `undefined !== null` is `true`). This can cause the function to resolve prematurely when the API isn't ready or the property hasn't been set. Use loose equality `!= null` instead to catch both `null` and `undefined`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Note
Migrates overlay rendering to a single high-DPI
OverlayCanvaswith offscreen layers and lerped animations, reducing DOM churn and centralizing drawing.SelectionBox/CrosshairwithOverlayCanvas(layers: crosshair/drag/selection/grabbed/processing); renderer now mounts the canvas and retainsSelectionLabelgetStateand plugin hooks withisCrosshairVisible,isSelectionBoxVisible,isDragBoxVisible,grabbedBoxes,selectionFilePathwaitForActive,waitForSelectionBox/Label/Source, context-menu waiters); specs updated to read fromwindow.__REACT_GRAB__globalThis.__REACT_GRAB_MODULE__Written by Cursor Bugbot for commit 72708a8. This will update automatically on new commits. Configure here.
Summary by cubic
Switched to a single canvas-based overlay for crosshair, selection, drag, and grabbed states to reduce DOM churn and improve performance. Updated renderer and E2E helpers to use the new overlay and internal state.
Refactors
Migration
Written for commit 72708a8. Summary will update on new commits.