fix(diagram): fix manual layout alignment tools not working#2791
Conversation
Extract syncFromXYFlow() from updateXYFlow() so that programmatic alignment changes are not overwritten by stale XYFlow positions. The position sync is now only called from drag-flow paths (onMove, flushPending), preserving aligned positions set by layoutAlign(). Fixes #2771 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 7e0655c The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
1a9d560 to
7e0655c
Compare
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR fixes manual layout alignment tools (Align Left/Right/Center/Top/Middle/Bottom) by refactoring state synchronization in the layout constraints module. A dedicated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/diagram/src/likec4diagram/useLayoutConstraints.spec.ts (1)
28-32: Consider using a typed placeholder instead ofas any.Per coding guidelines,
anyshould be avoided. For test mocks where the actual data isn't used, you could define a minimal type:- data: {} as any, + data: {} as Record<string, never>,This maintains type safety while still serving as a placeholder.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/diagram/src/likec4diagram/useLayoutConstraints.spec.ts` around lines 28 - 32, Replace the unsafe "data: {} as any" test placeholder with a properly typed minimal stub: declare a small interface/type or use an existing type for the node/element data and provide a minimal object that satisfies it (e.g., const minimalElementData: Partial<YourElementType> = {...} and then use data: minimalElementData as YourElementType). Update the test in useLayoutConstraints.spec.ts to reference that typed stub instead of `any`, ensuring the object includes any required fields used by the code under test and keeping the rest minimal.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/diagram/src/likec4diagram/useLayoutConstraints.spec.ts`:
- Around line 28-32: Replace the unsafe "data: {} as any" test placeholder with
a properly typed minimal stub: declare a small interface/type or use an existing
type for the node/element data and provide a minimal object that satisfies it
(e.g., const minimalElementData: Partial<YourElementType> = {...} and then use
data: minimalElementData as YourElementType). Update the test in
useLayoutConstraints.spec.ts to reference that typed stub instead of `any`,
ensuring the object includes any required fields used by the code under test and
keeping the rest minimal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 720c29ef-4e9e-49cc-ab59-609bf8e0e963
📒 Files selected for processing (3)
.changeset/fix-manual-layout-alignment.mdpackages/diagram/src/likec4diagram/useLayoutConstraints.spec.tspackages/diagram/src/likec4diagram/useLayoutConstraints.ts
✅ Actions performedReview triggered.
|
Summary
updateXYFlow()was resetting programmatically-set rect positions from stale XYFlow state before applying themsyncFromXYFlow()so position sync only happens in drag-flow paths, not when called fromlayoutAlign()Fixes #2771
Test plan
createLayoutConstraintsverifying programmatic positions are preserved🤖 Generated with Claude Code
Summary by CodeRabbit