-
Notifications
You must be signed in to change notification settings - Fork 194
fix(story): correctly set the perimeter on labels at page load #589
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
fix(story): correctly set the perimeter on labels at page load #589
Conversation
This change was added because of the way Storybook loads the story. The function getPerimeterPoint was being called before anything was painted on canvas and caused getBBox function to return 0 values. Fixes: maxGraph#545
WalkthroughThe pull request modifies the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
packages/html/stories/PerimeterOnLabelBounds.stories.ts (1)
Line range hint
44-63
: Document the label bounds growth valueThe 3px growth value for label bounds appears to be a magic number. Consider documenting why this specific value was chosen or making it configurable.
if (perimeter && terminal?.text?.boundingBox) { // Adds a small border to the label bounds + // Note: 3px growth provides sufficient padding to prevent edge-label overlap + // while maintaining visual clarity const b = terminal.text.boundingBox.clone(); b.grow(3);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/html/stories/PerimeterOnLabelBounds.stories.ts
(1 hunks)
🔇 Additional comments (1)
packages/html/stories/PerimeterOnLabelBounds.stories.ts (1)
112-133
: Verify similar patterns in other stories
Let's check if other stories might need similar fixes or already have better solutions implemented.
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.
LGTM, tested locally. Thanks for the contribution.
PR Checklist
maxGraph
, and you are assigned to the issue.packages/core/_tests_
or a new or altered Storybook story inpackages/html/stories
(an existing story may also demonstrate the change). Use the existingPerimeterOnLabelBounds.stories
or no docs changes are needed.Overview
Storybook rendering caused this issue, nothing in core code has been changed, only the setTimeout has been added.
Video of how it works with this change:
The function getPerimeterPoint was being called before anything was painted on canvas and caused getBBox function to return 0 values.
bounds.mov
Notes
Fixes: #545
Summary by CodeRabbit
Bug Fixes
Documentation
setTimeout
implementation.