{{ message }}
fix(story): correctly set the perimeter on labels at page load#589
Merged
tbouffard merged 2 commits intoJan 6, 2025
Merged
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
There was a problem hiding this comment.
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.
tbouffard
approved these changes
Jan 6, 2025
tbouffard
left a comment
Member
There was a problem hiding this comment.
LGTM, tested locally. Thanks for the contribution.
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.

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.storiesor 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
setTimeoutimplementation.