fix: normalize exported polygon points against the rendered canvas - #213
burakeyler wants to merge 1 commit into
Conversation
showCytoArray divided by a hardcoded 260px half-extent, but the SVG has no viewBox and fills its container, so at most viewport widths the exported points left the -1..1 range and the visible centre did not export 0. Use the same rect-derived normalizeToCanvas the hover readout uses, so the export and the readout agree. Fixes meshery-extensions#212 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Burak Eyler <burakeyler@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesCanvas normalization
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Exported coordinates now use the rendered canvas dimensions consistently with hover readouts and avoid division by zero when no rendered size exists. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
Fixes #212
Symptom
Exported polygon coordinates are meant to be in Cytoscape's
-1..1range, butshowCytoArraynormalized with a hardcoded260px half-extent while the SVG (noviewBox,width: 100%) is typically ~834×518. Points near the right edge exported ~2.0, and the visible centre didn't export 0 — and the numbers depended on window width.Fix
Takes the first option from the issue (not the
viewBoxdesign change):showCytoArraynow calls the existingnormalizeToCanvas(x, y, rect)withboardRef.current.getBoundingClientRect(), the same helperhandlePointerMoveuses. So there's one normalizer for both the export and the hover readout, and they can't disagree. The comment onnormalizeToCanvasthat documented the divergence is updated.If the canvas has no rendered size (e.g. hidden), it now reports the existing "Failed to extract and normalize polygon points." error instead of dividing by zero.
This intentionally changes exported values for existing users, as discussed in the issue.
Verification
[0, 0]and the bottom-right corner[1, 1]; the issue's worked example (800 px wide,x = 400) now exports0instead of0.538.🤖 Generated with Claude Code
Summary by CodeRabbit