fix(canvas): keep background aligned with usable rect - #345
Merged
Merged
Conversation
Reviewer's GuideFixes Background geometry synchronization by atomically updating the full expanded usable rectangle from current state, preventing zero-valued coordinates from being skipped and keeping Background and PointerGrid aligned. Comprehensive canvas-level regression tests cover coordinate transitions, size changes, queued updates, and unmount cleanup. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
Preview is ready. |
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
Fix the stock canvas
BackgroundandPointerGridfalling out of sync with the usable rectangle when an expanded rectangle coordinate becomes zero. This is a maintenance fix for the supported v1 line, targetingmain.Background.extendedUsableRectwas initialized to(0, 0, 0, 0)but never updated. Geometry updates compared against this stale rectangle while writing to component state. As a result, a computedxoryof0was skipped: the initial state could remain incomplete, or the background/grid could keep an earlier nonzero origin even thoughhitTest.$usableRectalready included all content.Changes
getState(), including pending state updates, before applying it with onesetStatecall.Reproduction / manual verification
system.USABLE_RECT_GAP = 248and a nonzero-size graph container.{x: 800, y: 800, width: 200, height: 100}and let the scheduler render it. The expanded background starts at(552, 552).{x: 248, y: 248, width: 1800, height: 1400}, with its hitbox contributing to the usable rectangle. Keep the original block.hitTest.$usableRectshould be{x: 248, y: 248, width: 1800, height: 1400}. Both the background and grid must use{x: 0, y: 0, width: 2296, height: 1896}.Before the fix, the background/grid origin remains
(552, 552). Also repeat with the comment present before the initial render, then move/resize/remove it and test zero on each axis independently.Verification
npm run lint— passed.npm run typecheck— passed, including publish build and published Playwright consumer types.node_modules/.bin/jest --runInBand --ci— 32 suites, 350 tests passed; 4 skipped, 6 todo; 9 snapshots passed, without snapshot updates.npm run test:e2e— 186 Chromium tests passed.build/index.js— all 10 content/background/grid states passed; zero geometry mismatches. No diagnostic patch was used.3f2f668e194206ea913949bb09bc1add8d097c8c: re-run the nine new tests with onlyBackground.tsloaded from that revision at transform time. Six tests fail with the original geometry error and three pass; with the real fix all nine pass. Working sources were not reverted for this control.Validation covers library fixtures and the built library, not the original downstream application graph. Package publication is not part of this PR.
Summary by Sourcery
Keep canvas background geometry synchronized with the current usable rectangle.
Bug Fixes:
Enhancements:
Tests: